# How do Heroku Connect synchronization settings maintain real-time bidirectional data consistency with Salesforce?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, Heroku Connect Sync, Bidirectional Data Flow

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-heroku-connect-synchronization-settings-maintain-real-time-bidirectional-data-consistency-with

## 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:**
1. Salesforce to Postgres: the default polling mode checks `SystemModstamp` at an interval. Accelerated polling uses a push notification to trigger a pull sooner. The Bulk API is used for the large initial load.
2. Postgres to Salesforce: a database trigger writes changes to `_trigger_log`, and Heroku Connect sends them to Salesforce in batches.
3. The `_hc_lastop` column shows `PENDING`, `SYNCED` or `FAILED`, and `_hc_err` holds the error text.
4. 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:**
```sql
-- Find rows that failed to sync back to Salesforce
SELECT id, sfid, _hc_lastop, _hc_err
FROM salesforce.account
WHERE _hc_lastop = 'FAILED';
```

**Hidden gotchas & must-remember points:**
- "Within seconds" is a best case. Verify polling intervals and accelerated polling availability in the current Heroku docs.
- A mapped field type or length mismatch causes sync errors, so schema changes in Salesforce need a mapping review.
- Deleted records sync only if the `isdeleted` handling is on for the mapping.
- The sync respects the integration user's visibility, so missing rows are often a permissions issue.
- Heavy writes from Postgres can exhaust Salesforce API limits.
- It does not replicate sharing rules or record access.

**Best practice:** Use read-only mappings where you can, add external IDs, and watch the error columns and API usage.

---
Source: ForceChallenges · last updated 2026-11-02
