gavinchou commented on code in PR #40160:
URL: https://github.com/apache/doris/pull/40160#discussion_r1737852468
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java:
##########
@@ -1679,10 +1679,13 @@ private void transferToMaster() {
*/
void advanceNextId() {
long currentId = idGenerator.getBatchEndId();
- long currentNanos = System.nanoTime();
+ long currentMill = System.currentTimeMillis();
long nextId = currentId + 1;
- if (nextId < currentNanos) {
- nextId = currentNanos;
+ // Reserve at most 8 billion for use in case of bugs or frequent
reboots (21 billion reboots)
+ if ((1L << 63) - nextId < (1L << 33)) {
+ LOG.warn("nextId is too large: {}, it may be a bug and consider
backup and migration", nextId);
+ } else {
+ nextId = (currentId + 1) < currentMill ? currentMill : currentId +
(1L << 32);
Review Comment:
```suggestion
// Keep compatible with previous impl, the previous impl may
result in extreme large nextId,
// and guess there are no more than 1L<<32 (~4e9) ids used since
last reboot
nextId = (currentId + 1) < currentMill ? currentMill : currentId
+ (1L << 32);
```
--
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]