This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new c363830612a [chore] Reduce range of nextId when calling
advanceNextId() (#40160)
c363830612a is described below
commit c363830612a88c69841826a9d1112febc40398e3
Author: Gavin Chou <[email protected]>
AuthorDate: Tue Sep 3 23:24:57 2024 +0800
[chore] Reduce range of nextId when calling advanceNextId() (#40160)
The previous implementation may result in extremely large nextId.
---
fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 597fee4dd8a..23ba86e53cd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -1680,10 +1680,15 @@ public class Env {
*/
void advanceNextId() {
long currentId = idGenerator.getBatchEndId();
- long currentNanos = System.nanoTime();
+ long currentMill = System.currentTimeMillis();
long nextId = currentId + 1;
- if (nextId < currentNanos) {
- nextId = currentNanos;
+ // Reserve ~1 trillion for use in case of bugs or frequent reboots (~2
billion reboots)
+ if ((1L << 63) - nextId < (1L << 40)) {
+ LOG.warn("nextId is too large: {}, it may be a bug and consider
backup and migration", nextId);
+ } else {
+ // 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);
}
// ATTN: Because MetaIdGenerator has guaranteed that each id it
returns must have
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]