Revert "HBASE-21376 Add some verbose log to MasterProcedureScheduler"

This reverts commit 71224ee530.
This commit is contained in:
Michael Stack 2018-10-26 06:10:47 -07:00
parent 71224ee530
commit 940326d8f5
No known key found for this signature in database
GPG Key ID: 9816C7FC8ACC93D2
3 changed files with 23 additions and 68 deletions

View File

@ -82,9 +82,7 @@ public class MasterProcedureEnv implements ConfigurationObserver {
public MasterProcedureEnv(final MasterServices master, public MasterProcedureEnv(final MasterServices master,
final RSProcedureDispatcher remoteDispatcher) { final RSProcedureDispatcher remoteDispatcher) {
this.master = master; this.master = master;
boolean verbose = master.getConfiguration() this.procSched = new MasterProcedureScheduler();
.getBoolean("hbase.master.procedure.scheduler.verbose", false);
this.procSched = new MasterProcedureScheduler(verbose);
this.remoteDispatcher = remoteDispatcher; this.remoteDispatcher = remoteDispatcher;
} }

View File

@ -116,16 +116,6 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
private final SchemaLocking locking = new SchemaLocking(); private final SchemaLocking locking = new SchemaLocking();
private boolean verbose = false;
public MasterProcedureScheduler() {
}
public MasterProcedureScheduler(boolean verbose) {
this.verbose = verbose;
}
@Override @Override
public void yield(final Procedure proc) { public void yield(final Procedure proc) {
push(proc, isTableProcedure(proc), true); push(proc, isTableProcedure(proc), true);
@ -157,11 +147,11 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
if (!queue.getLockStatus().hasExclusiveLock()) { if (!queue.getLockStatus().hasExclusiveLock()) {
// if the queue was not remove for an xlock execution,put the queue back into execution // if the queue was not remove for an xlock execution,put the queue back into execution
queue.add(proc, addFront); queue.add(proc, addFront);
addToRunQueue(fairq, queue, proc, "queue doesn't have exclusivelock"); addToRunQueue(fairq, queue);
} else if (queue.getLockStatus().hasLockAccess(proc)) { } else if (queue.getLockStatus().hasLockAccess(proc)) {
// always add it to front as the have the lock access. // always add it to front as the have the lock access.
queue.add(proc, true); queue.add(proc, true);
addToRunQueue(fairq, queue, proc, "procedure has lock access"); addToRunQueue(fairq, queue);
} else { } else {
queue.add(proc, addFront); queue.add(proc, addFront);
} }
@ -195,9 +185,6 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
private <T extends Comparable<T>> Procedure<?> doPoll(final FairQueue<T> fairq) { private <T extends Comparable<T>> Procedure<?> doPoll(final FairQueue<T> fairq) {
final Queue<T> rq = fairq.poll(); final Queue<T> rq = fairq.poll();
if (rq == null || !rq.isAvailable()) { if (rq == null || !rq.isAvailable()) {
if (verbose && rq != null) {
LOG.debug("polled from {} but it is not available", rq);
}
return null; return null;
} }
@ -208,30 +195,20 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
final boolean xlockReq = rq.requireExclusiveLock(pollResult); final boolean xlockReq = rq.requireExclusiveLock(pollResult);
if (xlockReq && rq.getLockStatus().isLocked() && !rq.getLockStatus().hasLockAccess(pollResult)) { if (xlockReq && rq.getLockStatus().isLocked() && !rq.getLockStatus().hasLockAccess(pollResult)) {
// someone is already holding the lock (e.g. shared lock). avoid a yield // someone is already holding the lock (e.g. shared lock). avoid a yield
removeFromRunQueue(fairq, rq, pollResult, removeFromRunQueue(fairq, rq);
"exclusive lock not acquired: " + rq.getLockStatus());
return null; return null;
} }
rq.poll(); rq.poll();
if (rq.isEmpty() || xlockReq) { if (rq.isEmpty() || xlockReq) {
String why = ""; removeFromRunQueue(fairq, rq);
if (rq.isEmpty()) {
why += "runqueue is empty ";
}
if (xlockReq) {
why += "xlock is required for next procedure";
}
removeFromRunQueue(fairq, rq, pollResult, why);
} else if (rq.getLockStatus().hasParentLock(pollResult)) { } else if (rq.getLockStatus().hasParentLock(pollResult)) {
// if the rq is in the fairq because of runnable child // if the rq is in the fairq because of runnable child
// check if the next procedure is still a child. // check if the next procedure is still a child.
// if not, remove the rq from the fairq and go back to the xlock state // if not, remove the rq from the fairq and go back to the xlock state
Procedure<?> nextProc = rq.peek(); Procedure<?> nextProc = rq.peek();
if (nextProc != null && !Procedure.haveSameParent(nextProc, pollResult)) { if (nextProc != null && !Procedure.haveSameParent(nextProc, pollResult)) {
removeFromRunQueue(fairq, rq, pollResult, removeFromRunQueue(fairq, rq);
" parent holds the lock and the next one is not the child of the parent, next procid="
+ nextProc.getProcId());
} }
} }
@ -292,9 +269,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
while (treeMap != null) { while (treeMap != null) {
Queue<T> node = AvlTree.getFirst(treeMap); Queue<T> node = AvlTree.getFirst(treeMap);
treeMap = AvlTree.remove(treeMap, node.getKey(), comparator); treeMap = AvlTree.remove(treeMap, node.getKey(), comparator);
if (fairq != null) { if (fairq != null) removeFromRunQueue(fairq, node);
removeFromRunQueue(fairq, node, null, "clear is called");
}
} }
} }
@ -351,25 +326,16 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
} }
} }
private <T extends Comparable<T>> void addToRunQueue( private static <T extends Comparable<T>> void addToRunQueue(FairQueue<T> fairq, Queue<T> queue) {
FairQueue<T> fairq, Queue<T> queue, final Procedure proc, String why) {
if (!AvlIterableList.isLinked(queue) && !queue.isEmpty()) { if (!AvlIterableList.isLinked(queue) && !queue.isEmpty()) {
fairq.add(queue); fairq.add(queue);
if (verbose) {
LOG.debug("Adding {} to runqueue, triggered by {}, since {}",
queue.getKey(), proc, why);
}
} }
} }
private <T extends Comparable<T>> void removeFromRunQueue( private static <T extends Comparable<T>> void removeFromRunQueue(
FairQueue<T> fairq, Queue<T> queue, final Procedure proc, String why) { FairQueue<T> fairq, Queue<T> queue) {
if (AvlIterableList.isLinked(queue)) { if (AvlIterableList.isLinked(queue)) {
fairq.remove(queue); fairq.remove(queue);
if (verbose) {
LOG.debug("Remove {} from runqueue, triggered by {}, since {}",
queue.getKey(), proc, why);
}
} }
} }
@ -437,7 +403,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
LockAndQueue lock = locking.getServerLock(serverName); LockAndQueue lock = locking.getServerLock(serverName);
if (node.isEmpty() && lock.tryExclusiveLock(proc)) { if (node.isEmpty() && lock.tryExclusiveLock(proc)) {
removeFromRunQueue(serverRunQueue, node, proc, "tryCleanupServerQueue is called"); removeFromRunQueue(serverRunQueue, node);
removeServerQueue(serverName); removeServerQueue(serverName);
} }
} finally { } finally {
@ -565,8 +531,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
logLockedResource(LockedResourceType.TABLE, table.getNameAsString()); logLockedResource(LockedResourceType.TABLE, table.getNameAsString());
return true; return true;
} }
removeFromRunQueue(tableRunQueue, getTableQueue(table), procedure, removeFromRunQueue(tableRunQueue, getTableQueue(table));
"need to wait TableExclusiveLock, lockstatus=" + tableLock);
return false; return false;
} finally { } finally {
schedUnlock(); schedUnlock();
@ -590,8 +555,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
if (namespaceLock.releaseSharedLock()) { if (namespaceLock.releaseSharedLock()) {
waitingCount += wakeWaitingProcedures(namespaceLock); waitingCount += wakeWaitingProcedures(namespaceLock);
} }
addToRunQueue(tableRunQueue, getTableQueue(table), procedure, addToRunQueue(tableRunQueue, getTableQueue(table));
"table's exclusive lock is available");
wakePollIfNeeded(waitingCount); wakePollIfNeeded(waitingCount);
} finally { } finally {
schedUnlock(); schedUnlock();
@ -643,8 +607,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
final LockAndQueue tableLock = locking.getTableLock(table); final LockAndQueue tableLock = locking.getTableLock(table);
int waitingCount = 0; int waitingCount = 0;
if (tableLock.releaseSharedLock()) { if (tableLock.releaseSharedLock()) {
addToRunQueue(tableRunQueue, getTableQueue(table), procedure, addToRunQueue(tableRunQueue, getTableQueue(table));
"table's shard lock is available");
waitingCount += wakeWaitingProcedures(tableLock); waitingCount += wakeWaitingProcedures(tableLock);
} }
if (namespaceLock.releaseSharedLock()) { if (namespaceLock.releaseSharedLock()) {
@ -852,8 +815,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
waitingCount += wakeWaitingProcedures(namespaceLock); waitingCount += wakeWaitingProcedures(namespaceLock);
} }
if (systemNamespaceTableLock.releaseSharedLock()) { if (systemNamespaceTableLock.releaseSharedLock()) {
addToRunQueue(tableRunQueue, getTableQueue(TableName.NAMESPACE_TABLE_NAME), procedure, addToRunQueue(tableRunQueue, getTableQueue(TableName.NAMESPACE_TABLE_NAME));
"namespace exclusive lock is available");
waitingCount += wakeWaitingProcedures(systemNamespaceTableLock); waitingCount += wakeWaitingProcedures(systemNamespaceTableLock);
} }
wakePollIfNeeded(waitingCount); wakePollIfNeeded(waitingCount);
@ -883,9 +845,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
removeFromRunQueue(serverRunQueue, removeFromRunQueue(serverRunQueue,
getServerQueue(serverName, getServerQueue(serverName,
procedure instanceof ServerProcedureInterface ? (ServerProcedureInterface) procedure procedure instanceof ServerProcedureInterface ? (ServerProcedureInterface) procedure
: null), procedure, : null));
"need to wait ServerExclusiveLock, ownerid=" + lock
.getExclusiveLockProcIdOwner());
return false; return false;
} }
waitProcedure(lock, procedure); waitProcedure(lock, procedure);
@ -913,7 +873,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
addToRunQueue(serverRunQueue, addToRunQueue(serverRunQueue,
getServerQueue(serverName, getServerQueue(serverName,
procedure instanceof ServerProcedureInterface ? (ServerProcedureInterface) procedure procedure instanceof ServerProcedureInterface ? (ServerProcedureInterface) procedure
: null), procedure, "Server's exclusive lock is available"); : null));
int waitingCount = wakeWaitingProcedures(lock); int waitingCount = wakeWaitingProcedures(lock);
wakePollIfNeeded(waitingCount); wakePollIfNeeded(waitingCount);
} finally { } finally {
@ -988,8 +948,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
try { try {
final LockAndQueue lock = locking.getMetaLock(); final LockAndQueue lock = locking.getMetaLock();
if (lock.tryExclusiveLock(procedure)) { if (lock.tryExclusiveLock(procedure)) {
removeFromRunQueue(metaRunQueue, getMetaQueue(), procedure, removeFromRunQueue(metaRunQueue, getMetaQueue());
"need to wait MetaExclusiveLock, lockStatus=" + lock);
return false; return false;
} }
waitProcedure(lock, procedure); waitProcedure(lock, procedure);
@ -1013,8 +972,7 @@ public class MasterProcedureScheduler extends AbstractProcedureScheduler {
try { try {
final LockAndQueue lock = locking.getMetaLock(); final LockAndQueue lock = locking.getMetaLock();
lock.releaseExclusiveLock(procedure); lock.releaseExclusiveLock(procedure);
addToRunQueue(metaRunQueue, getMetaQueue(), procedure, addToRunQueue(metaRunQueue, getMetaQueue());
"meta's exclusive lock is available");
int waitingCount = wakeWaitingProcedures(lock); int waitingCount = wakeWaitingProcedures(lock);
wakePollIfNeeded(waitingCount); wakePollIfNeeded(waitingCount);
} finally { } finally {

View File

@ -118,10 +118,9 @@ abstract class Queue<TKey extends Comparable<TKey>> extends AvlLinkedNode<Queue<
@Override @Override
public String toString() { public String toString() {
return String.format("%s(%s, xlock=%s sharedLock=%s size=%s peek=%s)", return String.format("%s(%s, xlock=%s sharedLock=%s size=%s)", getClass().getSimpleName(), key,
getClass().getSimpleName(), key, lockStatus.hasExclusiveLock() ? lockStatus.hasExclusiveLock() ? "true (" + lockStatus.getExclusiveLockProcIdOwner() + ")"
"true (" + lockStatus.getExclusiveLockProcIdOwner() + ")" : : "false",
"false", lockStatus.getSharedLockCount(), size(), lockStatus.getSharedLockCount(), size());
(size() > 0 ? peek() : "null"));
} }
} }