Skip to content

[fix][txn] Fix SnapshotSegmentAbortedTxnProcessorImpl thread safety issue - #22384

Closed
nikam14 wants to merge 4 commits into
apache:masterfrom
nikam14:fix---22116
Closed

nikam14 wants to merge 4 commits into
apache:masterfrom
nikam14:fix---22116

Conversation

@nikam14

@nikam14 nikam14 commented Mar 29, 2024

Copy link
Copy Markdown
Contributor

Fixes #22116

Motivation

Fix SnapshotSegmentAbortedTxnProcessorImpl thread safety issue

Modifications

  1. Added volatile keyword to unsealedtxnIds variable.
  2. Same resource were accessed at same line , so modified it.
  3. Added synchronized keyword for data consistency

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Mar 29, 2024

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution @nikam14 .

Unfortunately fixing these issues isn't simple. This PR might be doing the right things, but without proper concurrency tests, it's hard to ensure that adding synchronized methods doesn't cause regressions such as dead-locks. The lack of tests isn't caused by this PR, but to get confidence for merging such PRs, it would have to be resolved.
Just viewing the code won't be a sufficient review.

@nikam14

nikam14 commented Apr 5, 2024

Copy link
Copy Markdown
Contributor Author

Thanks for the explanation @lhotari

@merlimat

Copy link
Copy Markdown
Contributor

Thanks @nikam14, and sorry this sat so long. Master has changed a lot since this PR: snapshot recovery was rewritten in #26335, and every read and write of aborts now runs under the TopicTransactionBuffer monitor. The locks added here are on different monitors that no writer takes, so they wouldn't close the remaining gaps. Those gaps are getStats → generateSnapshotStats running without that lock, and updateIndexWhenExecuteTheLatestTask copying unsealedTxnIds on the writer thread. I'm closing this as part of the backlog triage and will add those details to #22116, which stays open. A fix along those lines, with a concurrency test, would be very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SnapshotSegmentAbortedTxnProcessorImpl contains thread safety issues

3 participants