JacksonYao287 commented on pull request #2611:
URL: https://github.com/apache/ozone/pull/2611#issuecomment-914268170
> Can you explain the problem in bit detail here?
thanks @bshashikant for the review! when i investigate some issues in our
production cluster, i find the log below, which is in
`SequenceIdGenerator.java`
2021-09-03 12:50:38,632
[1114efaf-c975-4ea0-bc8b-c3309a57cc8d@group-58D600BFB107-StateMachineUpdater]
WARN org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator: Failed to allocate a
batch for localId, **expected lastId is 0**, actual lastId is
107544261438510000.
let us see the code below
```
public Boolean allocateBatch(String sequenceIdName,
Long expectedLastId, Long newLastId) {
Long lastId = sequenceIdToLastIdMap.computeIfAbsent(sequenceIdName,
key -> {
try {
Long idInDb = this.sequenceIdTable.get(key);
return idInDb != null ? idInDb : INVALID_SEQUENCE_ID;
} catch (IOException ioe) {
throw new RuntimeException("Failed to get lastId from db",
ioe);
}
});
if (!lastId.equals(expectedLastId)) {
LOG.warn("Failed to allocate a batch for {}, expected lastId is {},"
+
" actual lastId is {}.", sequenceIdName, expectedLastId, lastId);
return false;
}
```
`expected lastId is 0` means `sequenceIdToLastIdMap` does not contains
`sequenceIdName`(localId), and thus `INVALID_SEQUENCE_ID`(0) is assigned to
`lastId`. this is a long run ozone cluster , so local id should exist in
sequenceIdToLastIdMap.
for now , when leader reelection happens , the new leader will call
`reinitialize` , but in current `SequenceIdGenerator` does not initialize
`sequenceIdToLastIdMap` , which hold the latest state of `lastId`. so this is
what this patch does.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]