fix: close of wal is block when recovery (#41326)

issue: #41307

Signed-off-by: chyezh <chyezh@outlook.com>
pull/41233/merge
Zhen Ye 2025-04-18 16:14:35 +08:00 committed by GitHub
parent 43d982bd11
commit c893344289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -95,8 +95,8 @@ func (w *roWALAdaptorImpl) Close() {
// begin to close the wal.
w.Logger().Info("wal begin to close...")
w.lifetime.SetState(typeutil.LifetimeStateStopped)
w.lifetime.Wait()
close(w.available)
w.lifetime.Wait()
w.Logger().Info("wal begin to close scanners...")

View File

@ -112,8 +112,11 @@ func (w *walAdaptorImpl) Append(ctx context.Context, msg message.MutableMessage)
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-w.available:
return nil, status.NewOnShutdownError("wal is on shutdown")
case <-w.interceptorBuildResult.Interceptor.Ready():
}
// Setup the term of wal.
msg = msg.WithWALTerm(w.Channel().Term)
@ -184,13 +187,12 @@ func (w *walAdaptorImpl) Close() {
w.Logger().Info("wal begin to close, start graceful close...")
// graceful close the interceptors before wal closing.
w.interceptorBuildResult.GracefulCloseFunc()
w.Logger().Info("wal graceful close done, wait for operation to be finished...")
// begin to close the wal.
w.lifetime.SetState(typeutil.LifetimeStateStopped)
w.lifetime.Wait()
close(w.available)
w.lifetime.Wait()
w.Logger().Info("wal begin to close scanners...")