Skip to content

Commit

Permalink
Clear resume token on some events known to be unprocessable.
Browse files Browse the repository at this point in the history
This prevents hopeless retries. We should probably add other events to
this list, like OTHER, but we're currently not even using resume tokens,
so this is a TODO...
  • Loading branch information
prdoyle committed Jun 14, 2023
1 parent b3f0593 commit 1a0cfb8
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ private void eventProcessingLoop(Session session) {
}

private void processEvent(Session session, ChangeStreamDocument<Document> event) throws UnprocessableEventException {
switch (event.getOperationType()) {
case DROP:
case DROP_DATABASE:
case INVALIDATE:
// These events are hopeless. There is no way a resume could succeed.
// If we try, we'll simply cause another unnecessary reinitialization,
// which is not only wasteful, but can also cause the DisconnectedDriver
// retry to fail a second time and report a user-visible error. If we make
// sure not to try to re-process these events, we avoid all this.
lastProcessedResumeToken = event.getResumeToken();
break;
default:
break;
}
session.listener.onEvent(event);
lastProcessedResumeToken = event.getResumeToken();
}
Expand Down

0 comments on commit 1a0cfb8

Please sign in to comment.