Skip to content

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
apache:masterfrom
kgeisz:HBASE-30220-replica-can-become-second-active
Open

HBASE-30220: A replica cluster can have read-only mode disabled even when another active cluster already exists#8377
kgeisz wants to merge 3 commits into
apache:masterfrom
kgeisz:HBASE-30220-replica-can-become-second-active

Conversation

@kgeisz

@kgeisz kgeisz commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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.enabled variable from true to false in hbase-site.xml and then running update_all_config in the HBase shell. The current active cluster is tracked by having the cluster's ID in a file called active.cluster.suffix.id. This file does not exist when all clusters are replicas.

Key Changes

  1. Adds a volatile boolean flag called readOnlyTransitionBlocked to HBaseServerBase. This is used to track whether a cluster was prevented from becoming an active cluster due to another active cluster already existing.
    • If another active cluster exists when changing read-only from false to true, then readOnlyTransitionBlocked is set to true, and a new exception called ReadOnlyTransitionException is thrown in the HBase shell.
  2. Adds a static method to AbstractReadOnlyController called isAnotherClusterActive(). This returns true when the cluster ID in active.cluster.suffix.id does not match the current cluster.
  3. Adds logic to onConfigurationChange() in HMaster, HRegionServer, and HRegion to prevent the replica cluster from being promoted to an active cluster when another active cluster exists.
    • These methods does not return early when the read-only transition is blocked in case other coprocessors or variables need to be dynamically loaded.
  4. Read-only mode is still active and the ReadOnlyController coprocessors are still loaded if a cluster is blocked from becoming an active cluster.

…when another active cluster already exists

Code generated with Claude Opus 4.6 and modified by hand after

Change-Id: Ifb6992d1c9d6982cdcec0522d7b75ed9f985c0e3
@kgeisz kgeisz force-pushed the HBASE-30220-replica-can-become-second-active branch from f27629b to d5f43b0 Compare June 18, 2026 22:51
@kgeisz

kgeisz commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

These unit test failures are not relevant.

@anmolnar anmolnar requested review from charlesconnell and taklwu and removed request for charlesconnell July 7, 2026 19:47

@anmolnar anmolnar 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.

Only a few nitpicks from me.

* already exists on the same storage location.
*/
@InterfaceAudience.Public
public class ReadOnlyTransitionException extends DoNotRetryIOException {

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.

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) {

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 think setReadOnlyEnabledConfigurationCopy would be a better name for this method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java Outdated
…an in HBaseServerBase

Change-Id: I2794ed6ce5e6ea3665d55185c0938fa430525f85
@kgeisz kgeisz force-pushed the HBASE-30220-replica-can-become-second-active branch from 8619a4b to f72734c Compare July 10, 2026 19:29
Change-Id: Iecf2e678787193e9faabeb55ba21ebcc37a52808
@kgeisz kgeisz force-pushed the HBASE-30220-replica-can-become-second-active branch from f72734c to 59f8783 Compare July 10, 2026 19:49
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.

2 participants