Docs Menu

Invalid Resume Token

On this page

  • Overview
  • Stack Trace
  • Cause
  • Solutions
  • Temporarily Tolerate Errors
  • Delete Stored Offsets
  • Prevention

Learn how to recover from an invalid resume token in a MongoDB Kafka Connector source connector.

The following stack trace indicates that the source connector has an invalid resume token:

...
org.apache.kafka.connect.errors.ConnectException: ResumeToken not found.
Cannot create a change stream cursor
...
Command failed with error 286 (ChangeStreamHistoryLost): 'PlanExecutor
error during aggregation :: caused by :: Resume of change stream was not
possible, as the resume point may no longer be in the oplog
...

When the ID of your source connector's resume token does not correspond to any entry in your MongoDB deployment's oplog, your connector has no way to determine where to begin to process your MongoDB change stream. Click the following tabs to see scenarios in which you can experience this issue:

For more information on the oplog, see the MongoDB Manual.

For more information on change streams, see the Change Streams guide.

You can recover from an invalid resume token using one of the following strategies:

You can configure your source connector to tolerate errors while you produce a change stream event that updates the connector's resume token. This recovery strategy is the simplest, but there is a risk that your connector briefly ignores errors unrelated to the invalid resume token. If you aren't comfortable briefly tolerating errors in your deployment, you can delete stored offsets instead.

To configure your source connector to temporarily tolerate errors:

  1. Set the errors.tolerance option to tolerate all errors:

    errors.tolerance="all"
  2. Insert, update, or delete a document in the collection referenced by your source connector to produce a change stream event that updates your connector's resume token.
  3. Once you produce a change stream event, set the errors.tolerance option to no longer tolerate errors:

    errors.tolerance="none"

For more information on the errors.tolerance option, see the Error Handling and Resume Properties page.

You can delete your Kafka Connect offset data, which contains your resume token, to allow your connector to resume processing your change stream. This strategy is more complex than the preceding strategy, but does not risk tolerating errors unrelated to the invalid resume token.

The steps to perform this strategy depend on whether you are running Kafka Connect in distributed mode or standalone mode. Click on the tab corresponding to the mode of your deployment:

To prevent invalid resume token errors caused by an infrequently updated namespace, enable heartbeats. Heartbeats is a feature of your source connector that causes your connector to update its resume token at regular intervals as well as when the contents of your source MongoDB namespace changes.

Specify the following option in your source connector configuration to enable heartbeats:

heartbeat.interval.ms=<a positive integer>

To learn more about heartbeats, see the Error Handling and Resume Properties guide.

Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.