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

fix(server): Reorder ExecuteAsync callback seqlock check #873

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

dranikpg
Copy link
Contributor

Currently we re-use transactions in the non-atomic multi mode and the callback in ExecuteAsync looks like the following:

mask = GetMask(shard)
seq_after = Add(seqlock, 0, release)

if seq_after == seq_old and mask & ARMED: Poll()

However it might happen that the transaction is already being re-used when the callback is run, so we should avoid accessing the mask and just quietly drop the callback.

I suggest accessing the mask only when checking the seqlock, which means that the wait barrier didn't finish and all state remained untouched.

seq_after = Load(seqlock, acquire)
if seq_after == seq_old and GetMask(shard) & ARMED: Poll()

I must admit I don't understand your "trick".

we use fetch_add with release trick to make sure that local_mask is loaded before we load seq_after

Why?

We could gain similar result with "atomic_thread_fence(acquire)"

Thats what I did and release-acquire is standard practice. But how is it similar? Its the opposite in fact

Signed-off-by: Vladislav Oleshko <[email protected]>
@dranikpg dranikpg requested a review from romange February 23, 2023 15:32
@dranikpg dranikpg marked this pull request as ready for review February 23, 2023 20:50
Copy link
Collaborator

@romange romange left a comment

Choose a reason for hiding this comment

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

Yeah, I do not know what I was thinking.

@romange romange merged commit be4ef01 into dragonflydb:main Feb 24, 2023
@dranikpg dranikpg deleted the reorder-cb-check branch February 27, 2023 16:39
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