From 70bd44db72871c7cf16b8e03539fb936f7eba1e1 Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Tue, 16 Jan 2024 10:56:42 +0000 Subject: [PATCH] kvserver: acquire `Replica.mu` when returning reproposal error Epic: none Release note: None --- pkg/kv/kvserver/replica_application_result.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/kv/kvserver/replica_application_result.go b/pkg/kv/kvserver/replica_application_result.go index 0ed13dcd9477..e3ee7fef4f38 100644 --- a/pkg/kv/kvserver/replica_application_result.go +++ b/pkg/kv/kvserver/replica_application_result.go @@ -407,13 +407,14 @@ func (r *Replica) tryReproposeWithNewLeaseIndex(ctx context.Context, origCmd *re // The tracker wants us to forward the request timestamp, but we can't // do that without re-evaluating, so give up. The error returned here // will go to back to DistSender, so send something it can digest. - err := kvpb.NewNotLeaseHolderError( + r.mu.RLock() + defer r.mu.RUnlock() + return kvpb.NewNotLeaseHolderError( *r.mu.state.Lease, r.store.StoreID(), r.mu.state.Desc, "reproposal failed due to closed timestamp", ) - return err } // Some tests check for this log message in the trace. log.VEventf(ctx, 2, "retry: proposalIllegalLeaseIndex")