if you open rsgroup, hbase-site.xml contains below configuration.
And you shut down the whole HBase cluster in the way:
- first shut down region server one by one
- shut down master
Then you restart whole cluster in the way:
- start master
- start regionserver
The hbase:meta region can not be re-online and the rsgroup can not be initialized successfully.
The logs show that hbase:meta region is not online and rsgroup keeps retrying to initialize.
but why the hbase:meta region is not online?
The info-level logs and jstack had not enough infomation, so I added some debug logs in test-source-code. Then i checked the master`s logs and region server`s logs, and found the meta region assign procedure which hold the meta region lock not completed and not released the lock forever, so the recoverMetaProcedure could not be executed.
Why the first procedure not completed and not released meta region lock?
In the test logs, i found when assignmentManager assigned the region, it need to call the rsgroup balancer which have not been initialized completely, so throw NPE. As a result, the procedure not completed and not released the lock forever.
As shown in the figure named bug2.png listed in attachments, when we shutdown the last region server, the master submit a ServerCrashProcedure. In the procedure, it will reassign hbase:meta region, but at that moment, there is no online region server, so the procedure can not be executed completely. Then we shut down master, the ServerCrashProcedure and it`a subProcedures are stored into procedureStore.
When we restart master, at first, the master blocks waiting for becoming active master. after becoming active master, it starts procedureExecutor. The procedureExecutor start to read procedure from procedureStore and the pre serverCrashProcedure submit a assign region task to assignmentManager`s queue. The processQueue thread and active-master thread block waiting for online region servers. when we start a region server, the active-master thread do some operations and init rsgroup balancer. At the same time, the processQueue thread start to call balancer. If the processQueue thread run faster than active master, the processQueue thread will throw NPE. As a result, the procedure not complete and not release hbase:meta region lock forever.
Now, my solution is that initializing the balancer before calling startServiceThreads in finishActiveMasterInitialization() of HMaster.But this may have some side effects for master.
Based on stack`s suggestion, i re-submit a new patch which waiting for initializing rsgroup balancer before calling balance-methods.