-
Notifications
You must be signed in to change notification settings - Fork 16
Fix change stream lag calculation. #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix change stream lag calculation. #79
Conversation
tdq45gj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR comment says it adds a test. Are we still adding it?
internal/verifier/change_stream.go
Outdated
| curTs, err := extractTimestampFromResumeToken(cs.ResumeToken()) | ||
| if err == nil { | ||
| lagSecs := curTs.T - sess.OperationTime().T | ||
| lagSecs := int32(sess.OperationTime().T) - int32(curTs.T) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be prone to overflow. Can we convert T (uint32) to int64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good call
|
@tdq45gj I added the test. (Somehow I omitted it inadvertently earlier.) |
tdq45gj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
The previous logic was backwards, which caused uint overflow.
This adds a test that usually passes without this change but should occasionally fail. (It should always pass, though, with this change.)