HBASE-30220: A replica cluster can have read-only mode disabled even when another active cluster already exists#8377
Open
kgeisz wants to merge 3 commits into
Conversation
…when another active cluster already exists Code generated with Claude Opus 4.6 and modified by hand after Change-Id: Ifb6992d1c9d6982cdcec0522d7b75ed9f985c0e3
f27629b to
d5f43b0
Compare
Contributor
Author
|
These unit test failures are not relevant. |
anmolnar
reviewed
Jul 7, 2026
anmolnar
left a comment
Contributor
There was a problem hiding this comment.
Only a few nitpicks from me.
| * already exists on the same storage location. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| public class ReadOnlyTransitionException extends DoNotRetryIOException { |
Contributor
There was a problem hiding this comment.
nit: Could encapsulate a String field identifying the current active cluster's ID and emitted to log when the exception is converted to string.
| * Returns a copied version of the provided Configuration object that has | ||
| * {@link HConstants#HBASE_GLOBAL_READONLY_ENABLED_KEY} set to true. | ||
| */ | ||
| public static Configuration getReadOnlyEnabledConfigurationCopy(Configuration conf) { |
Contributor
There was a problem hiding this comment.
I think setReadOnlyEnabledConfigurationCopy would be a better name for this method.
Contributor
Author
There was a problem hiding this comment.
IMO the name should use get instead of set since the method returns a modified copy of the configuration. The original configuration is left untouched.
…an in HBaseServerBase Change-Id: I2794ed6ce5e6ea3665d55185c0938fa430525f85
8619a4b to
f72734c
Compare
Change-Id: Iecf2e678787193e9faabeb55ba21ebcc37a52808
f72734c to
59f8783
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/HBASE-30220
AI Usage
These changes were generated using Claude Opus 4.6 and then modified by hand.
Summary
In a Read-Replica cluster setup, the active cluster allows both reads and writes, while the replica clusters only allow reads. In this type of setup, only one cluster should be an active cluster at a time. Although the current code prevents starting an active cluster while another one exists, it is still possible to simple turn a running replica into an active cluster despite another active cluster already existing. The changes in this pull request prevent this behavior.
A cluster is promoted from replica to active by changing the
hbase.global.readonly.enabledvariable fromtruetofalseinhbase-site.xmland then runningupdate_all_configin the HBase shell. The current active cluster is tracked by having the cluster's ID in a file calledactive.cluster.suffix.id. This file does not exist when all clusters are replicas.Key Changes
volatile booleanflag calledreadOnlyTransitionBlockedto HBaseServerBase. This is used to track whether a cluster was prevented from becoming an active cluster due to another active cluster already existing.falsetotrue, thenreadOnlyTransitionBlockedis set totrue, and a new exception calledReadOnlyTransitionExceptionis thrown in the HBase shell.staticmethod toAbstractReadOnlyControllercalledisAnotherClusterActive(). This returns true when the cluster ID inactive.cluster.suffix.iddoes not match the current cluster.onConfigurationChange()inHMaster,HRegionServer, andHRegionto prevent the replica cluster from being promoted to an active cluster when another active cluster exists.