# How do Batch Data Synchronization processes maintain multi-system data consistency across enterprise architectures?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, Batch Synchronization, ETL Processing

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-batch-data-synchronization-processes-maintain-multi-system-data-consistency-across-enterprise

## Answer

**Basics:** Not all data needs real-time updates. Nightly or hourly ETL (extract, transform, load) between Salesforce and a warehouse, ERP or MDM keeps systems aligned cheaply, uses bulk-optimized APIs and avoids burdening user transactions. Consistency here means eventual consistency with a defined lag, with one system of record per field.

**How it works:**
1. Decide direction and source of truth per object and field.
2. Extract only changes since the last run (a **watermark**) using `SystemModstamp` (indexed and updated by system processes, unlike `LastModifiedDate`), or use CDC events.
3. Transform and map fields, resolving references via External IDs.
4. Load through Bulk API 2.0 using **upsert** with an External ID so reruns are safe.
5. Process success and failure results; retry failures; store the new watermark only after success.
6. Reconcile counts and checksums, and detect deletes.

**Advanced / deep dive:** Deletes need explicit handling: use `queryAll` with `IsDeleted = true` (records stay in the Recycle Bin for 15 days, so a sync missing more than that window loses delete information), the REST `getDeleted` call, or CDC delete events; or use soft-delete flags. For huge initial loads use PK chunking and parallel mode, but order loads parent-before-child and group by parent to avoid row-lock errors. Respect the API allocation and run heavy jobs off-peak. Salesforce-side options: scheduled Batch Apex with Database.Stateful for outbound pushes (Database.AllowsCallouts if it calls out), Flow, or middleware like MuleSoft or Informatica. For conflicts use a rule (last-write-wins by timestamp, or source-of-truth priority), never silently overwrite. Platform tools: Data Cloud or CRM Analytics connectors for analytics copies.

**Code / config example:**
```sql
-- Incremental extract using a watermark (stored from the last successful run)
SELECT Id, Name, Ext_Id__c, SystemModstamp
FROM Account
WHERE SystemModstamp > 2026-10-31T22:00:00Z
ORDER BY SystemModstamp ASC
```

**Hidden gotchas & must-remember points:**
- Use `SystemModstamp`, not `LastModifiedDate`, for reliable incremental extracts.
- Move the watermark only after a fully successful run, or use an overlap window and rely on idempotent upserts.
- Deleted records are invisible to normal queries.
- Record locking breaks parallel loads on shared parents.
- Time zones: Salesforce stores UTC; keep extracts in UTC.
- Bulk results expire; save them.

**Best practice:** Use External-ID upserts, incremental watermarks, reconciliation counts and a documented system of record for every field.

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