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

We may have the deadlock in ZSet::InterStore(as well as other similar APIs) #1715

Closed
git-hulk opened this issue Aug 30, 2023 · 0 comments · Fixed by #1726
Closed

We may have the deadlock in ZSet::InterStore(as well as other similar APIs) #1715

git-hulk opened this issue Aug 30, 2023 · 0 comments · Fixed by #1726
Assignees

Comments

@git-hulk
Copy link
Member

We may have the deadlock in ZSet::InterStore(as well as other similar APIs) if the dst key was inside the source key list since the OverWrite function will also lock the dst key: https://github.com/apache/kvrocks/blob/unstable/src/types/redis_zset.cc#L635

This issue was found by TSAN in CI: https://github.com/apache/kvrocks/actions/runs/6022265431/job/16338859035?pr=1712

Originally posted by @git-hulk in #1712 (comment)

@git-hulk git-hulk changed the title We may have the deadlock in ZSet::InterStore(as well as other similar APIs) if the dst key was inside the source key list since the OverWrite function will also lock the dst key: https://github.com/apache/kvrocks/blob/unstable/src/types/redis_zset.cc#L635 We may have the deadlock in ZSet::InterStore(as well as other similar APIs) if the dst key was inside the source key list Aug 30, 2023
@git-hulk git-hulk changed the title We may have the deadlock in ZSet::InterStore(as well as other similar APIs) if the dst key was inside the source key list We may have the deadlock in ZSet::InterStore(as well as other similar APIs) Aug 30, 2023
@enjoy-binbin enjoy-binbin self-assigned this Sep 2, 2023
enjoy-binbin added a commit that referenced this issue Sep 3, 2023
CI TSAN show ZINTERSTORE may has a deadlock after introducing
locks to DEL in #1712. In ZSet::InterStore if the dst key was
inside the source key list we may have a deadlock since the
OverWrite function will also lock the dst key.

In this PR, we split Inter in ZSet::InterStore into a separate
function, just like the Set apis.

After this PR, after the CI verification in #1712, it can pass
the CI verification now. Closes #1715

This PR also do a saved_cnt cleanup since it is same as members.size().
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 a pull request may close this issue.

2 participants