Re: Confusion on the warning "Lock write succeeded but took too long"

HadoopMarc <bi...@...>


This is more about english than about java.

I think the author means that if you get an answer after 10 seconds that you have the lock for 1 second starting 5 seconds ago, you need a new lock.

HTH,    Marc

Op zaterdag 31 oktober 2020 om 02:25:01 UTC+1 schreef c...@...:

Environment: JG-0.5.2 with HBase and Elasticsearch

When running a java program to delete verteics and edges, many warnings "Lock write succeeded but took too long" show up.

Wanting to know what happens, I check the code and got confused,

protected ConsistentKeyLockStatus writeSingleLock(KeyColumn lockID, StoreTransaction txh) throws Throwable {

final StaticBuffer lockKey = serializer.toLockKey(lockID.getKey(), lockID.getColumn());
StaticBuffer oldLockCol = null;

for (int i = 0; i < lockRetryCount; i++) {
WriteResult wr = tryWriteLockOnce(lockKey, oldLockCol, txh);
if (wr.isSuccessful() && wr.getDuration().compareTo(lockWait) <= 0) {
final Instant writeInstant = wr.getWriteTimestamp();
final Instant expireInstant =;
return new ConsistentKeyLockStatus(writeInstant, expireInstant);
oldLockCol = wr.getLockCol();
handleMutationFailure(lockID, lockKey, wr, txh);
tryDeleteLockOnce(lockKey, oldLockCol, txh);
// TODO log exception or successful too-slow write here
throw new TemporaryBackendException("Lock write retry count exceeded");

In the code shown above, when wr.getDuration()  greater than lockWait, the warning "Lock write succeeded but took too long" will be printed, and than continue the for loop until to limit.  

And my confusion is that why we continue the for loop when the write is successful (even though it took too long, it's still a successful operation, right?)

Any help would be greatly appreciated.

Join { to automatically receive all group messages.