Richard Gao
10/08/2025, 4:05 PMFailure in source: Saved offset is not valid. Please reset the connection, and then increase oplog retention and/or increase sync frequency to prevent his from happening in the future
errors when using source-mongo-v2. We found out that there was a fix and implemented that fix. It resolved the majority of our issues except for two of our sources. On those two sources we still get the errors. Our team has looked at the source oplog and says there shouldn't be issues: Our oplog has a min retention time of two weeks and 50GB. We see that the resume token is actually even still valid when we try it out! I was wondering if there might be anyone that has experienced the same thing and might have some recommendations on what to check.kapa.ai
10/08/2025, 4:05 PMread access on the local database. When this permission is missing, you may see warnings like: Unable to query for op log stats, exception: {}Command failed with error 13 (Unauthorized): ‘not authorized on local to execute command { collStats: “oplog.rs”, $db: “local”, ... }’ After granting the correct permissions, the logs should show the actual oplog size, e.g.: Max oplog size is 78383153152 bytes Free space in oplog is 10821718016 bytes [See user report and mitigation](https://github.com/airbytehq/airbyte/issues/48496#issuecomment-2879259974) ### 2. State/Resume Token Issues There have been cases where the Airbyte state contains multiple resume tokens, and only one is updated, leading to failures. This was addressed in the 2.0.4 fix, but some users still see issues with state not updating as expected for certain sources. Manually updating the stale resume token with the current one has been used as a workaround, but this is not a long-term solution. If you see two state entries, this could be a sign of the issue. ### 3. Data Movement and Sync Frequency If there is little or no data movement in the source collection, the LSN (log sequence number) may not advance, and the resume token can become invalid even if the oplog is large. Ensure that at least some data is being written to the source between syncs, or consider increasing sync frequency to ensure the connector can always find the resume token in the oplog window. This is especially important if your syncs are infrequent or your collections are mostly static[Connector Limitations](https://docs.airbyte.com/integrations/sources/mongodb-v2/mongodb-v2-troubleshooting#connector-limitations). ### 4. Read Preference and Other Configurations Some users reported using readPreference=secondaryPreferred and still encountering the issue. There is no clear evidence in the knowledge sources that this is the root cause, but it is worth testing with different read preferences if possible. ### 5. Version-Specific Bugs There have been ongoing fixes and dev builds (e.g., 2.0.4-dev.5b6b076be4) addressing these issues. If you are not already on the latest stable or dev build, consider testing with the most recent version, as some users have reported improvements after upgrading, though not all issues are fully resolved for every environment. --- Summary of Recommendations: - Double-check that your Airbyte MongoDB user has read access on the local database so the connector can accurately read oplog stats. - Review your Airbyte state for multiple resume tokens and ensure only the correct, up-to-date token is present. - Ensure there is some data movement in the source collections between syncs, or increase sync frequency. - Test with the latest connector version or dev build if you haven't already. - If the issue persists, consider opening a new GitHub issue with detailed logs, oplog stats, and state information, as the Airbyte team is actively working on these problems and may request more details for further troubleshooting. If you have already checked all of the above and the problem persists, unfortunately, the knowledge sources do not provide a definitive root cause or solution for your specific scenario. The issue appears to be complex and may require direct support from the Airbyte team with detailed logs and configuration information. Let me know if you need help with specific log analysis or further troubleshooting steps!Richard Gao
10/08/2025, 5:52 PMkapa.ai
10/08/2025, 5:52 PMkapa.ai
10/08/2025, 5:52 PMread access to the local database in MongoDB allows the Airbyte connector to query the oplog statistics directly. This is important because, without this permission, the connector cannot determine the actual size and retention window of the oplog. When the connector lacks this access, it falls back to a default or assumed oplog size, which may be incorrect and can lead to the "Saved offset is not valid" error—even if your actual oplog is large enough. A user reported that after granting read@local to the Airbyte MongoDB user, the warning about being unable to query oplog stats disappeared from the logs, and the connector was able to retrieve and use the correct oplog size. This resolved the offset error for them: > We gave "read@local" to the Airbyte MongoDB user. Once that is done, the above warning is gone, and instead you'll see something like this: > > > Max oplog size is 78383153152 bytes > Free space in oplog is 10821718016 bytes > > > The logs now show that the connector was able to retrieve the oplog size and thus, can do its optimization. By doing so, the error mention in the issue description disappeared. > > [See user report and mitigation](https://github.com/airbytehq/airbyte/issues/48496#issuecomment-2879259974) In summary, giving read access to the local database helps the Airbyte MongoDB connector accurately determine oplog stats, which is critical for reliable incremental syncs and avoiding offset errors.Richard Gao
10/08/2025, 5:57 PMkapa.ai
10/08/2025, 5:57 PMkapa.ai
10/08/2025, 5:57 PMUnable to query for op log stats, exception: {}class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap') is a known issue that has been reported by other Airbyte users as well. This error occurs even after granting the correct read access to the local database. It is not a permissions issue, but rather a bug in the connector code where the type returned by MongoDB for the oplog size is sometimes an Integer instead of a Long, and the connector does not handle this type mismatch gracefully. This specific problem was discussed in [issue #62833](https://github.com/airbytehq/airbyte/issues/62833), where users reported that the connector would fail with this class cast exception, leading to the "Saved offset is not valid" error. The Airbyte team released a fix in a development build (e.g., 2.0.4-dev.5b6b076be4) to address this type handling issue. Recommendation: If you are still seeing this error after updating permissions, you should ensure you are running a version of the MongoDB source connector that includes the fix for this bug. If you are already on a recent version and still encounter the issue, it may be worth testing the latest dev build or reaching out to the Airbyte team for further support, as this is a connector-side bug and not something you can resolve with configuration or permissions alone. For more details, see the discussion and fix in [issue #62833](https://github.com/airbytehq/airbyte/issues/62833).Richard Gao
10/08/2025, 6:00 PMkapa.ai
10/08/2025, 6:00 PMkapa.ai
10/08/2025, 6:00 PMclass java.lang.Integer cannot be cast to class java.lang.Long error in the MongoDB source connector is referenced in the discussion of [issue #62833](https://github.com/airbytehq/airbyte/issues/62833). The Airbyte team provided a development build (2.0.4-dev.5b6b076be4) that addresses this issue, but the specific pull request (PR) number is not explicitly mentioned in the knowledge sources provided. The changelog for the connector also does not directly reference a PR for this particular type-casting fix. Therefore, based on the available knowledge sources, I’m sorry, but there is no direct link to the exact PR that fixed this issue. The information only confirms that the fix is included in the 2.0.4 version and its related dev build, as discussed in the GitHub issue comments[issue #62833](https://github.com/airbytehq/airbyte/issues/62833).Manuel Pozo
10/09/2025, 10:14 AMRichard Gao
10/09/2025, 2:31 PM