Loading

Data discrepancy in SOQL Queries filtered by SystemModstamp or LastModifiedDate

게시 일자: Jul 19, 2024
상세 설명
Symptoms:
A first SOQL query doesn’t extract those records, but a second one executed some time after, returns them correctly. Seems like there’s data discrepancy.

Explanation:
What is happening here is that there’s an inflight transaction updating those records while the first query is executed. The SystemModstamp or LastModifiedDate fields are set when records are processed, but they are only visible after the transaction commits. And, in this case, that happens after the first query ends, so those records are not extracted by it. If the transaction finishes processing in the period between the first and the second queries, the second query will extract those records, since their SystemModstamp or LastModifiedDate fields now have a visible value within the filtered time frame.
솔루션
It is not safe to perform data replication operations using SOQL Queries filtered by SystemModstamp or LastModifiedDate. There’s no way for you to take inflight transactions into account.

Instead, you should use one of the Salesforce features that allow to perform data replication operations safely and efficiently.

We strongly recommend using Platform Events, Change Data Capture or Streaming API.

You can also consider using our classic Replication API.

Check this other Knowledge Article for more information about Data Replication.
 
Knowledge 기사 번호

000391120

 
로드 중
Salesforce Help | Article