From 069b3014c2669da3bc36705e6a935183927a75f2 Mon Sep 17 00:00:00 2001 From: Max Ignatenko Date: Fri, 24 Nov 2023 22:57:37 +0000 Subject: [PATCH] Fix TID generator to avoid duplicates Third call on the same microsecond would not match the `if` condition and would return the same value as the first call. --- repo/tid.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo/tid.go b/repo/tid.go index 4ab31d410..eb648eea9 100644 --- a/repo/tid.go +++ b/repo/tid.go @@ -30,8 +30,8 @@ func NextTID() string { t := uint64(time.Now().UnixMicro()) ltLock.Lock() - if lastTime == t { - t++ + if lastTime >= t { + t = lastTime + 1 } lastTime = t