Repository navigation
HBASE-30581 Removing an RSGroup can race with creating a namespace that uses it - #8938
Open
SpookyJumpyBeans wants to merge 1 commit into
Open
SpookyJumpyBeans wants to merge 1 commit into
SpookyJumpyBeans wants to merge 1 commit into
Conversation
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-30581
CreateNamespaceProcedurechecks the namespace's RSGroup only inCREATE_NAMESPACE_PREPAREand writes the namespace two states later.removeRSGrouponly looks at namespaces that already exist, so it can remove the group in between, and the namespace is written withhbase.rsgroup.namepointing at a group that no longer exists. Creating a table in that namespace then fails inMasterProcedureUtil.checkGroupExistsuntil the group is recreated or the namespace is changed.ModifyNamespaceProcedurehas the same gap when it moves a namespace to a group.Changes
removeRSGroupalso refuses while an unfinishedCreateNamespaceProcedureorModifyNamespaceProcedurereferences the group:This includes procedures that have not reached their prepare state yet, which is on the safe side.
RSGroupInfoManager.getRSGroupAfterPendingChanges, whichRSGroupInfoManagerImplimplements as asynchronizedversion ofgetRSGroup, the same lockremoveRSGroupholds while it checks and removes the group. A procedure is in the executor before it runs prepare, so either its check runs first andremoveRSGroupsees the procedure, or the removal finishes first and the check fails. Without this, a procedure could pass its check in the window betweenremoveRSGroupscanning the procedures and the group removal being written. The default method in the interface just callsgetRSGroup, forDisabledRSGroupInfoManager.CreateNamespaceProcedureandModifyNamespaceProcedureget agetNamespaceDescriptor()accessor.Since the manager lock is also held by
moveServerswhile 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:
CreateTableProcedurechecks the group beforeCREATE_TABLE_WRITE_FS_LAYOUTwrites the descriptor, and bothremoveRSGroupandmoveServersonly look at existing table descriptors. The fix there is different (it also involvesmoveServers), so I filed it separately as HBASE-30583.Tests
TestRemoveRSGroupWhileCreatingNamespaceholds aCreateNamespaceProcedure(and, in a second test, aModifyNamespaceProcedure) after its group check, empties the group, and checks thatremoveRSGroupis 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,TestCreateNamespaceProcedureandTestModifyNamespaceProcedureon Linux (WSL) with JDK 21.