From 3433f2858c60af0075eb04f42714360839809ac1 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 9 Sep 2024 15:40:50 +0900 Subject: [PATCH] fix: return err when the flush process is executing Signed-off-by: hlts2 --- pkg/agent/core/ngt/service/ngt.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index b65f180b3f..4c1ce19650 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -908,7 +908,7 @@ func (n *ngt) Start(ctx context.Context) <-chan error { } return ctx.Err() case <-tick.C: - if n.vq != nil && !n.IsFlushing() && n.vq.IVQLen() >= n.alen { + if n != nil && n.vq != nil && !n.IsFlushing() && n.vq.IVQLen() >= n.alen { err = n.CreateIndex(ctx, n.poolSize) } case <-limit.C: @@ -1299,8 +1299,11 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { } }() - if n.isReadReplica { + switch { + case n.isReadReplica: return errors.ErrWriteOperationToReadReplica + case n.IsFlushing(): + return errors.ErrFlushingIsInProgress } ic := n.vq.IVQLen() + n.vq.DVQLen()