How do Heroku Connect synchronization settings maintain real-time bidirectional data consistency with Salesforce?
Answer
Basics: You choose a sync mode per mapping. The service handles field mapping, deletes, and writing back changes, so you do not write sync code. It is not "real time" in the strict sense, because the latency depends on mode, volume and API limits.
How it works:
- Salesforce to Postgres: the default polling mode checks
SystemModstampat an interval. Accelerated polling uses a push notification to trigger a pull sooner. The Bulk API is used for the large initial load. - Postgres to Salesforce: a database trigger writes changes to
_trigger_log, and Heroku Connect sends them to Salesforce in batches. - The
_hc_lastopcolumn showsPENDING,SYNCEDorFAILED, and_hc_errholds the error text. - Failures, such as a validation rule error, stay visible in the table and the dashboard.
Advanced / deep dive: Each mapping's write behavior can be "read-only" or "read-write". Conflicts are resolved by last write, with no merge. Use an external ID field for upserts so that retries do not create duplicates. Salesforce API call usage grows with the number of mappings and write volume. You can keep a mapping smaller by selecting fewer fields. For a stronger consistency guarantee in the app, do not read your own write immediately from Postgres and assume Salesforce already has it. If you need strict real-time or transactional behavior, use API calls or events instead of replication.
Code / config example:
-- Find rows that failed to sync back to Salesforce
SELECT id, sfid, _hc_lastop, _hc_err
salesforce.account
_hc_lastop ;