Skip to content
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

CDCRecordStream: replace mutex with atomics #814

Merged
merged 1 commit into from
Dec 13, 2023
Merged

Conversation

serprex
Copy link
Contributor

@serprex serprex commented Dec 13, 2023

No description provided.

@serprex serprex requested a review from iskakaushik December 13, 2023 05:22
}

func (r *CDCRecordStream) GetLastCheckpoint() (int64, error) {
r.checkpointMutex.Lock()
defer r.checkpointMutex.Unlock()

if !r.lastCheckpointSet {
Copy link
Contributor Author

@serprex serprex Dec 13, 2023

Choose a reason for hiding this comment

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

lastCheckpointSet seems kind of funny since it gets written to by Close without synchronization & here seems to only be an assertion. Seems like this struct has a mode between collection/read which would be cleaner as a channel which gets sent first/last checkpoint id at end of pull or something (where we need to somehow communicate back to some process which has been storing a pointer to this from before pull began & is using some external sync to only read first/last after Close)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that channels to communicate most fields in this struct would be a good idea. I only wish channels had a GetOrWait primitive :-)

@serprex serprex merged commit f33c34f into main Dec 13, 2023
12 checks passed
@serprex serprex deleted the atomic-checkpointid branch December 19, 2023 16:36
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