<@U04S8PLJWMT> A mongodb databse that I am syncing...
# ask-ai
i
@kapa.ai A mongodb databse that I am syncing, just had been inserted 7k documents. The sync is scheduled once per day, at the scheduled sync, it loaded 0 records, the next morning I launched the sync manually and it loaded everything. Why, what is the delay in syncing about?
k
Based on the information in the knowledge sources, there are a few possible reasons why your scheduled daily sync did not load the newly inserted 7,000 MongoDB documents, but a manual sync the next morning did: 1. Oplog Retention and Change Streams: If you are using incremental syncs with MongoDB's Change Streams, Airbyte relies on the MongoDB Oplog to track changes. If the Oplog retention period is too short, or if the initial import takes longer than the Oplog retention, Airbyte may miss changes or encounter issues like "invalid resume token." This can result in missed records during scheduled syncs. Increasing the Oplog size or sync frequency is recommended to avoid missing data, especially if your sync interval is close to or exceeds the Oplog retention window. However, your case describes a successful manual sync after a failed scheduled one, which suggests the Oplog was still valid, but something else prevented the scheduled sync from loading records at that time [MongoDB v2 Troubleshooting: Connector Limitations](https://docs.airbyte.com/integrations/sources/mongodb-v2/mongodb-v2-troubleshooting#connector-limitations). 2. Sync Scheduling and Overlap: Airbyte only allows one sync per connection to run at a time. If a previous sync was still running or had not completed properly, the scheduled sync might have been skipped or not processed new records. The next manual sync, triggered after the previous one had finished, would then process the new records as expected [Sync Schedules](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-schedules). 3. State Management Issues: There are known issues where Airbyte's state management can cause records to be missed or not loaded, especially if there are errors or interruptions during syncs. For example, if the state message is not properly updated or if there is a NullPointerException in the replication process, records may be extracted but not loaded, as seen in some MongoDB connector issues. A subsequent manual sync may reset the state and allow records to be loaded [[source-mongodb] Records get extracted and loaded but it only shows extracted and 0 loaded](https://github.com/airbytehq/airbyte/issues/45133). 4. Connector or Destination-Specific Delays: Sometimes, the destination system or the connector itself may have temporary issues (e.g., network, resource contention, or internal errors) that prevent records from being loaded during a scheduled sync, but these issues may resolve by the time a manual sync is run. Summary: The most likely causes are either a temporary issue with state management or a sync overlap/lockout that prevented the scheduled sync from loading records. The manual sync, run after the system was in a clean state, was able to process and load the new documents. If this happens frequently, review your Oplog retention, sync frequency, and check for any errors in the Airbyte logs around the time of the scheduled sync for more details. If you need more precise troubleshooting, reviewing the Airbyte logs for the scheduled sync that loaded 0 records would be necessary. The knowledge sources do not provide a single definitive cause, but these are the most probable explanations based on known Airbyte and MongoDB connector behaviors.
i
@kapa.ai ther are absolutely no sync failures, my syncs work very fine, just says 0 records loaded, at certain timess it loads the docuemnts but htere is this delay which is bad for us, we sync every half of hour, and still have issuees
k
A message from kapa.ai
Based on the knowledge sources, there are several reports of MongoDB incremental syncs with Airbyte showing similar symptoms: syncs run successfully (no failures), but sometimes load 0 records even though new documents have been inserted. Later syncs (manual or scheduled) then load the missing records. This "delay" or "lag" in data loading is a known issue, but the root cause is not always clear. Here are the most relevant findings from the knowledge sources: 1. Oplog/Change Stream State Issues Airbyte's MongoDB connectors rely on the Oplog or Change Streams for incremental syncs. If the connector cannot correctly read the Oplog size (for example, due to missing permissions), it may fall back to a default or incorrect value, which can cause the connector to miss changes or delay picking them up. Granting the Airbyte user the
read@local
permission to access the Oplog has resolved similar issues for some users. If the connector cannot read the Oplog stats, it may not optimize or track changes correctly, leading to delayed syncs even when there are no failures reported ([source-mongodb] Incremental sync error on specific collection - Saved offset is not valid)[https://github.com/airbytehq/airbyte/issues/48496]. 2. State/Resume Token Handling There are multiple reports of Airbyte's MongoDB connector having issues with state management or resume tokens, resulting in syncs that extract but do not load records, or that load records only after a subsequent sync. This can happen even if the Oplog retention and sync frequency are set correctly. Sometimes, the connector's state is not updated as expected, causing a lag in when new records are actually loaded ([source-mongodb] Records get extracted and loaded but it only shows extracted and 0 loaded)[https://github.com/airbytehq/airbyte/issues/45133]. 3. No Explicit Root Cause or Fix The knowledge sources do not provide a definitive root cause or a universal fix for this "delayed loading" issue when there are no sync failures. However, they do suggest that Oplog access, state management, and possibly resource constraints or connector bugs could be contributing factors. What you can do: - Check Oplog Permissions: Ensure the Airbyte MongoDB user has
read@local
permission so the connector can accurately read Oplog stats. - Review Connector Version: Some issues have been addressed in newer connector versions or with dev builds. Upgrading may help if you are not on the latest version. - Monitor Logs: Look for warnings about Oplog access or state handling in the Airbyte logs, even if the syncs are marked as successful. - Increase Sync Frequency: While you already sync every 30 minutes, some users still report issues even with frequent syncs, so this alone may not resolve the problem. Summary: The knowledge sources confirm that delayed loading of records (with successful syncs reporting 0 records loaded) is a known but unresolved issue with Airbyte's MongoDB connector, often related to Oplog access or state management. There is no single fix, but ensuring proper permissions and using the latest connector version are recommended steps. If the problem persists, you may want to follow or contribute to the ongoing GitHub issues for more targeted support ([source-mongodb] Incremental sync error on specific collection - Saved offset is not valid)[https://github.com/airbytehq/airbyte/issues/48496], [source-mongodb] Records get extracted and loaded but it only shows extracted and 0 loaded)[https://github.com/airbytehq/airbyte/issues/45133].