Skip to content

HBASE-30581 Removing an RSGroup can race with creating a namespace that uses it - #8938

Open
SpookyJumpyBeans wants to merge 1 commit into
apache:masterfrom
SpookyJumpyBeans:HBASE-30581
Open

SpookyJumpyBeans wants to merge 1 commit into
apache:masterfrom
SpookyJumpyBeans:HBASE-30581

Conversation

@SpookyJumpyBeans

@SpookyJumpyBeans SpookyJumpyBeans commented Nov 27, 2026 •

Copy link
Copy Markdown

https://issues.apache.org/jira/browse/HBASE-30581

CreateNamespaceProcedure checks the namespace's RSGroup only in CREATE_NAMESPACE_PREPARE and writes the namespace two states later. removeRSGroup only looks at namespaces that already exist, so it can remove the group in between, and the namespace is written with hbase.rsgroup.name pointing at a group that no longer exists. Creating a table in that namespace then fails in MasterProcedureUtil.checkGroupExists until the group is recreated or the namespace is changed. ModifyNamespaceProcedure has the same gap when it moves a namespace to a group.

Changes

  • removeRSGroup also refuses while an unfinished CreateNamespaceProcedure or ModifyNamespaceProcedure references the group:
throw new ConstraintException("RSGroup " + groupName + " is referenced by namespace "
  + ns.getName() + ", which is being created or modified (pid=" + proc.getProcId() + ")");

This includes procedures that have not reached their prepare state yet, which is on the safe side.

  • The namespace procedures check their group with a new RSGroupInfoManager.getRSGroupAfterPendingChanges, which RSGroupInfoManagerImpl implements as a synchronized version of getRSGroup, the same lock removeRSGroup holds while it checks and removes the group. A procedure is in the executor before it runs prepare, so either its check runs first and removeRSGroup sees the procedure, or the removal finishes first and the check fails. Without this, a procedure could pass its check in the window between removeRSGroup scanning the procedures and the group removal being written. The default method in the interface just calls getRSGroup, for DisabledRSGroupInfoManager.
  • CreateNamespaceProcedure and ModifyNamespaceProcedure get a getNamespaceDescriptor() accessor.

Since the manager lock is also held by moveServers while it moves regions, a namespace procedure's prepare can wait for a server move to finish.

Not changed

Creating or modifying a table that uses a group has a similar gap: CreateTableProcedure checks the group before CREATE_TABLE_WRITE_FS_LAYOUT writes the descriptor, and both removeRSGroup and moveServers only look at existing table descriptors. The fix there is different (it also involves moveServers), so I filed it separately as HBASE-30583.

Tests

TestRemoveRSGroupWhileCreatingNamespace holds a CreateNamespaceProcedure (and, in a second test, a ModifyNamespaceProcedure) after its group check, empties the group, and checks that removeRSGroup is refused, that the procedure succeeds, and that the namespace references the group, which still exists. Without this change both tests fail: the group is removed and the namespace is written referencing it.

I ran it with TestRSGroupsAdmin1, TestRSGroupsAdmin2, TestRSGroupsBasics, TestRSGroupsCPHookCalled, TestCreateNamespaceProcedure and TestModifyNamespaceProcedure on Linux (WSL) with JDK 21.

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.

1 participant