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


"c...@gmail.com" <cjx...@...>
 

Thanks, I misunderstood the method.

在2020年11月6日星期五 UTC+8 下午9:33:16<HadoopMarc> 写道:

Hi,

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,

@Override
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 = writeInstant.plus(lockExpire);
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.


HadoopMarc <bi...@...>
 

Hi,

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,

@Override
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 = writeInstant.plus(lockExpire);
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.


"c...@gmail.com" <cjx...@...>
 

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,

@Override
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 = writeInstant.plus(lockExpire);
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.