Skip to content

HBASE-29644: Refresh_meta triggering compaction on user table - #7385

Merged
anmolnar merged 1 commit into
apache:HBASE-29081from
sharmaar12:meta_compaction
Nov 13, 2025
Merged

HBASE-29644: Refresh_meta triggering compaction on user table#7385
anmolnar merged 1 commit into
apache:HBASE-29081from
sharmaar12:meta_compaction

Conversation

@sharmaar12

Copy link
Copy Markdown
Contributor

Link to JIRA: https://issues.apache.org/jira/browse/HBASE-29644

Description:
Consider the two cluster setup with one being active and one read replica. If active cluster create a table with FILE based SFT. If you add few rows through active and do flushes to create few Hfiles and then do refresh_meta from read replica its triggering minor compaction. Which should not happen via read replica, it may create inconsitencies because active is not aware of that event.

Cause:
This is happening because we should block the compaction event in ReadOnlyController but we missed adding read only guard to preCompactSelection() function.

Fix:
Add internalReadOnlyGuard to preCompactSelection() in ReadOnlyController

@sharmaar12sharmaar12 changed the title Refresh_meta triggering compaction on user tableHBASE-29644: Refresh_meta triggering compaction on user tableOct 14, 2025
@Apache-HBase

This comment has been minimized.

@wchevreuilwchevreuil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's nice to have such safeguard in case we face any unexpected attempt of performing a write operation in a read-only cluster, but it's not an acceptable solution for the use case here. We know something triggers compaction when the refresh_meta command is executed on a read replica cluster, so we should find out where that's been triggered and put a check there to avoid waste of resources, rather than relying on exception being thrown. That would cause log pollution and could create confusion for operators.

@sharmaar12

Copy link
Copy Markdown
ContributorAuthor

@wchevreuil Thanks for the suggestion, we will check what is the root cause of this.

@Apache-HBase

This comment has been minimized.

@anmolnar

anmolnar commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

@sharmaar12 Try the following: create a unit test which triggers the problem, attach debugger and set a breakpoint in your event handler preCompactSelection. From stack trace you will see the root cause of compaction.

@sharmaar12
sharmaar12force-pushed the meta_compaction branch 2 times, most recently from e7cb788 to a279f76CompareOctober 28, 2025 14:42
@sharmaar12

Copy link
Copy Markdown
ContributorAuthor

@wchevreuil@anmolnar
The current fix follows the approach to discard the compaction request whenever the read-only mode is on. Do you think we need to find all the callers which can execute the compaction thread and block the request at that level?

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

Comment on lines +348 to +352
if (isReadOnlyEnabled()) {
LOG.info("Ignoring compaction request for " + region + ",because read-only mode is on.");
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why we don't simply disable compaction altogether in the read replica cluster? See line #343 in CompactionSplit, there's already a check for compaction enabled flag. I would rather refrain from polluting CompactiSplit code with logic for read replica.

@sharmaar12sharmaar12Oct 29, 2025

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We can use that approach but then one issue I can think of is that hbase.global.readonly.enabled property is dynamically configurable using update_all_config but is it true for hbase.hstore.compaction.enabled also?

@anmolnaranmolnarOct 29, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like @wchevreuil 's idea.
How about adding the read-only check to the getter?

publicbooleanisCompactionsEnabled() {
returncompactionsEnabled && !isReadOnlyEnabled();
}

You don't need to dynamically change the compaction flag.
wdyt?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Then we may need to at least modify the log messages to mention that either compaction is disabled or readonly mode is on. Otherwise compaction may be enabled but we are logging it as disabled because of read-only mode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LOG.info("Ignoring compaction request for " + region + (!isReadOnlyEnabled ? ", because compaction is disabled." : " in read-only mode"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

or just leave it as is, not a biggy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hbase.hstore.compaction.enabled

The actual property name is hbase.regionserver.compaction.enabled. Compaction is actual "switchable" via the Admin.compactionSwitch() method (we also expose an hbase shell command for that). The CompactSplit thread itself exposes a switchCompaction method which could be called on both RS startup and the dynamic config handler for the hbase.global.readonly.enabled property.

@anmolnaranmolnarOct 30, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Be careful with switching the property directly. User might have intentionally disabled it and you should not enable it when go from R/O -> R/W mode. My approach seems safer to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Be careful with switching the property directly. User might have intentionally disabled it and you should not enable it when go from R/O -> R/W mode. My approach seems safer to me.

Good point. Let's just do all checks inside isCompactionsEnabled, as @anmolnar suggested.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@anmolnar

Copy link
Copy Markdown
Contributor

@sharmaar12 Do you think that the unit test failure is related to the patch?

@sharmaar12

Copy link
Copy Markdown
ContributorAuthor

@sharmaar12 Do you think that the unit test failure is related to the patch?

@anmolnar It may not be because, it passes on my local setup. Also our code only execute when read-only mode is on.

In previous run https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7385/3/ also there were 8 failures which were different from these and they also passed in my local setup.

Could you please help me rerun the job?

@Apache-HBase

This comment has been minimized.

@anmolnar

Copy link
Copy Markdown
Contributor

Looks like the build has been restarted. @wchevreuil would you please review again?

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

Link to JIRA: https://issues.apache.org/jira/browse/HBASE-29644
Description:
Consider the two cluster setup with one being active and one read replica. If active cluster create a table with FILE based SFT. If you add few rows through active and do flushes to create few Hfiles and then do refresh_meta from read replica its triggering minor compaction. Which should not happen via read replica, it may create inconsitencies because active is not aware of that event.
Cause:
This is happening because we should block the compaction event in ReadOnlyController but we missed adding read only guard to preCompactSelection() function.
Fix:
Add internalReadOnlyGuard to preCompactSelection() in ReadOnlyController
@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 31sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
_ HBASE-29081 Compile Tests _
+1 💚mvninstall3m 41sHBASE-29081 passed
+1 💚compile3m 23sHBASE-29081 passed
-0 ⚠️checkstyle0m 15s/buildtool-branch-checkstyle-hbase-server.txtThe patch fails to run checkstyle in hbase-server
+1 💚spotbugs1m 37sHBASE-29081 passed
+1 💚spotless0m 52sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚mvninstall3m 9sthe patch passed
+1 💚compile3m 24sthe patch passed
+1 💚javac3m 24sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
-0 ⚠️checkstyle0m 12s/buildtool-patch-checkstyle-hbase-server.txtThe patch fails to run checkstyle in hbase-server
+1 💚spotbugs1m 42sthe patch passed
+1 💚hadoopcheck12m 20sPatch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚spotless0m 45spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 11sThe patch does not generate ASF License warnings.
39m 59s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7385/9/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#7385
JIRA IssueHBASE-29644
Optional Testsdupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
unameLinux 786d00ed274e 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionHBASE-29081 / e6d2559
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count85 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7385/9/console
versionsgit=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 31sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ HBASE-29081 Compile Tests _
+1 💚mvninstall3m 36sHBASE-29081 passed
+1 💚compile0m 59sHBASE-29081 passed
+1 💚javadoc0m 28sHBASE-29081 passed
+1 💚shadedjars6m 22sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚mvninstall3m 17sthe patch passed
+1 💚compile1m 0sthe patch passed
+1 💚javac1m 0sthe patch passed
+1 💚javadoc0m 28sthe patch passed
+1 💚shadedjars6m 13spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit240m 49shbase-server in the patch passed.
269m 22s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7385/9/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#7385
JIRA IssueHBASE-29644
Optional Testsjavac javadoc unit compile shadedjars
unameLinux bf0c2b90e7ef 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionHBASE-29081 / e6d2559
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7385/9/testReport/
Max. process+thread count4194 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7385/9/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@anmolnar
anmolnar merged commit 459db1d into apache:HBASE-29081Nov 13, 2025
1 check passed
@sharmaar12
sharmaar12 deleted the meta_compaction branch December 16, 2025 14:36
anmolnar pushed a commit that referenced this pull request Mar 13, 2026
Link to JIRA: https://issues.apache.org/jira/browse/HBASE-29644
Description:
Consider the two cluster setup with one being active and one read replica. If active cluster create a table with FILE based SFT. If you add few rows through active and do flushes to create few Hfiles and then do refresh_meta from read replica its triggering minor compaction. Which should not happen via read replica, it may create inconsitencies because active is not aware of that event.
Cause:
This is happening because we should block the compaction event in ReadOnlyController but we missed adding read only guard to preCompactSelection() function.
Fix:
Add internalReadOnlyGuard to preCompactSelection() in ReadOnlyController
anmolnar pushed a commit that referenced this pull request Apr 8, 2026
Link to JIRA: https://issues.apache.org/jira/browse/HBASE-29644
Description:
Consider the two cluster setup with one being active and one read replica. If active cluster create a table with FILE based SFT. If you add few rows through active and do flushes to create few Hfiles and then do refresh_meta from read replica its triggering minor compaction. Which should not happen via read replica, it may create inconsitencies because active is not aware of that event.
Cause:
This is happening because we should block the compaction event in ReadOnlyController but we missed adding read only guard to preCompactSelection() function.
Fix:
Add internalReadOnlyGuard to preCompactSelection() in ReadOnlyController
anmolnar pushed a commit that referenced this pull request Apr 10, 2026
Link to JIRA: https://issues.apache.org/jira/browse/HBASE-29644
Description:
Consider the two cluster setup with one being active and one read replica. If active cluster create a table with FILE based SFT. If you add few rows through active and do flushes to create few Hfiles and then do refresh_meta from read replica its triggering minor compaction. Which should not happen via read replica, it may create inconsitencies because active is not aware of that event.
Cause:
This is happening because we should block the compaction event in ReadOnlyController but we missed adding read only guard to preCompactSelection() function.
Fix:
Add internalReadOnlyGuard to preCompactSelection() in ReadOnlyController
anmolnar pushed a commit that referenced this pull request May 5, 2026
Link to JIRA: https://issues.apache.org/jira/browse/HBASE-29644
Description:
Consider the two cluster setup with one being active and one read replica. If active cluster create a table with FILE based SFT. If you add few rows through active and do flushes to create few Hfiles and then do refresh_meta from read replica its triggering minor compaction. Which should not happen via read replica, it may create inconsitencies because active is not aware of that event.
Cause:
This is happening because we should block the compaction event in ReadOnlyController but we missed adding read only guard to preCompactSelection() function.
Fix:
Add internalReadOnlyGuard to preCompactSelection() in ReadOnlyController
Sign up for freeto 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.

4 participants

@sharmaar12@Apache-HBase@anmolnar@wchevreuil