From 34f2e70f0c9a84690400a7fd098f1d5c898b2442 Mon Sep 17 00:00:00 2001 From: gueFDF <3237455241@qq.com> Date: Wed, 26 Apr 2023 18:23:04 +0800 Subject: [PATCH] nsqd:It is more efficient to deal with the case where the sequence is used up here --- nsqd/guid.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nsqd/guid.go b/nsqd/guid.go index 89ba83e9e..52318ee3a 100644 --- a/nsqd/guid.go +++ b/nsqd/guid.go @@ -63,7 +63,10 @@ func (f *guidFactory) NewGUID() (guid, error) { f.sequence = (f.sequence + 1) & sequenceMask if f.sequence == 0 { f.Unlock() - return 0, ErrSequenceExpired + //wait for next millisecond + for ts <= f.lastTimestamp { + ts = time.Now().UnixNano() >> 20 + } } } else { f.sequence = 0