Skip to content

Conversation

@FGasper
Copy link
Collaborator

@FGasper FGasper commented Nov 22, 2024

REVIEW NOTE

It probably makes sense to review this PR’s 2 commits separately.


This is necessary for testing migration-verifier’s change stream in mongosync’s nondeterministic tests. It entails a small refactor of the change stream code so that both the change stream’s creation and iteration happen under a retryer.

Additionally, this makes GetNewClusterTime() return an actual new cluster time rather than returning the current one. This simplifies reasoning about the change stream’s handling of the writesOff timestamp.

@FGasper FGasper marked this pull request as ready for review November 23, 2024 01:27
@FGasper FGasper force-pushed the felipe_retry_change_stream branch 3 times, most recently from 8231711 to 03853c7 Compare November 23, 2024 22:48
@FGasper FGasper requested a review from tdq45gj November 25, 2024 03:31
@FGasper FGasper changed the title Retry on change stream failures. REP-5318 Retry on change stream failures. Nov 25, 2024
@FGasper FGasper force-pushed the felipe_retry_change_stream branch from 03853c7 to 1348a60 Compare November 25, 2024 03:34
Copy link
Collaborator

@tdq45gj tdq45gj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think we need to call IterationSuccess when iterating the change stream.

// StartChangeStream starts the change stream.
func (verifier *Verifier) StartChangeStream(ctx context.Context) error {
// Result seems a bit simpler than messing with 2 separate channels.
resultChan := make(chan mo.Result[primitive.Timestamp])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. Could you clarify what result does this resultChan expect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result holds a “payload, or error”. It’s a common pattern in Rust.

The alternative would be 2 separate channels then a select on those.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it hold the result from createChangeStream? Could we use a more descriptive name such as createChangeStreamResultChan?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s the first change stream creation’s result. I’ve reshuffled the code a bit to clarify that.

@FGasper FGasper requested a review from tdq45gj November 25, 2024 18:20
Copy link
Collaborator

@tdq45gj tdq45gj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Previously this function actually returned the most recent cluster
time rather than creating a new cluster time. This changeset makes it
now create a new time instead. This simplifies the change stream’s
handling of the writesOff timestamp because the writesOff timestamp is
separate from any change event.
@FGasper FGasper force-pushed the felipe_retry_change_stream branch from 0f074f1 to 1547534 Compare November 25, 2024 19:21
This entails a small refactor of the change stream code so that the
change stream’s creation and iteration both happen under a retryer.
@FGasper FGasper force-pushed the felipe_retry_change_stream branch from 1547534 to f4fcc05 Compare November 25, 2024 19:23
@FGasper FGasper merged commit da9b7a6 into mongodb-labs:main Nov 25, 2024
33 checks passed
@FGasper FGasper deleted the felipe_retry_change_stream branch November 25, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants