Skip to content

HBASE-29394 Possible race in BufferedMutatorOverAsyncBufferedMutator #7089

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

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

Apache9
Copy link
Contributor

@Apache9 Apache9 commented Jun 11, 2025

No description provided.

@Apache9 Apache9 self-assigned this Jun 11, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a potential race condition in BufferedMutatorOverAsyncBufferedMutator by adding a synchronized block within the asynchronous callback and by introducing a targeted test case to validate the race scenario.

  • Introduces a synchronized block in the callback of BufferedMutatorOverAsyncBufferedMutator to update shared state safely.
  • Adds TestBufferedMutatorOverAsyncBufferedMutator.java to simulate and verify the race condition behavior.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
hbase-client/src/main/java/org/apache/hadoop/hbase/client/BufferedMutatorOverAsyncBufferedMutator.java Synchronizes listener callback to prevent race conditions.
hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestBufferedMutatorOverAsyncBufferedMutator.java Adds a race condition test to validate correct exception handling and flush behavior.

@Apache9
Copy link
Contributor Author

Apache9 commented Jun 11, 2025

The key thing here is that, for a failed mutation, in the callback in mutate method, we remove the future from futures, and then, before we add the exception to errors, internalFlush method is called and finished, so in the method, we can not get the future since it has already been removed from the futures field, and also we can not get the exception from the errors field since it has not been added to the errors field yet.

The solution is to also use synchronized(this) in the callback.

});
mockedPair.when(() -> Pair.newPair(any(), any())).then(i -> {
beforeFlush.countDown();
afterFlush.await(5, TimeUnit.SECONDS);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we need to use timed await because after the fixing in this PR, the above flush operation can not finish before we leave the synchronized block, so after fixing finally we will timeout here and fall through.
Before the fix, the await will return soon and then the test will fail.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 29s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚 mvninstall 3m 16s master passed
+1 💚 compile 0m 21s master passed
+1 💚 javadoc 0m 18s master passed
+1 💚 shadedjars 6m 4s branch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 7s the patch passed
+1 💚 compile 0m 21s the patch passed
+1 💚 javac 0m 21s the patch passed
+1 💚 javadoc 0m 16s the patch passed
+1 💚 shadedjars 6m 4s patch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚 unit 1m 36s hbase-client in the patch passed.
23m 2s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7089/1/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR #7089
Optional Tests javac javadoc unit compile shadedjars
uname Linux 1994fa6d4adb 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 8d62f09
Default Java Eclipse Adoptium-17.0.11+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7089/1/testReport/
Max. process+thread count 325 (vs. ulimit of 30000)
modules C: hbase-client U: hbase-client
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7089/1/console
versions git=2.34.1 maven=3.9.8
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 26s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
_ master Compile Tests _
+1 💚 mvninstall 3m 44s master passed
+1 💚 compile 0m 53s master passed
+1 💚 checkstyle 0m 20s master passed
+1 💚 spotbugs 0m 53s master passed
+1 💚 spotless 0m 54s branch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 25s the patch passed
+1 💚 compile 0m 53s the patch passed
+1 💚 javac 0m 53s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 18s the patch passed
+1 💚 spotbugs 0m 57s the patch passed
+1 💚 hadoopcheck 11m 58s Patch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚 spotless 0m 50s patch has no errors when running spotless:check.
_ Other Tests _
+1 💚 asflicense 0m 11s The patch does not generate ASF License warnings.
33m 29s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7089/1/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #7089
Optional Tests dupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
uname Linux cbe92dae08f9 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 8d62f09
Default Java Eclipse Adoptium-17.0.11+9
Max. process+thread count 81 (vs. ulimit of 30000)
modules C: hbase-client U: hbase-client
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7089/1/console
versions git=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache9 Apache9 merged commit c9df607 into apache:master Jun 12, 2025
1 check passed
Apache9 added a commit that referenced this pull request Jun 12, 2025
…7089)

Signed-off-by: Nihal Jain <nihaljain@apache.org>
(cherry picked from commit c9df607)
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.

3 participants