SpookyJumpyBeans opened a new pull request, #8938: URL: https://github.com/apache/hbase/pull/8938
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: ```java 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'll file it separately. ### 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
