mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
[backport 3.5] server: don't panic in readonly serializable txn
Problem: We pass grpc context down to applier in readonly serializable txn. This context can be cancelled for example due to timeout. This will trigger panic inside applyTxn Solution: Only panic for transactions with write operations fixes https://github.com/etcd-io/etcd/issues/14110 main PR https://github.com/etcd-io/etcd/pull/14149 Signed-off-by: Bogdan Kanivets <bkanivets@apple.com>
This commit is contained in:
@@ -16,6 +16,7 @@ package mvcc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"go.etcd.io/etcd/api/v3/mvccpb"
|
||||
"go.etcd.io/etcd/pkg/v3/traceutil"
|
||||
@@ -156,7 +157,7 @@ func (tr *storeTxnRead) rangeKeys(ctx context.Context, key, end []byte, curRev i
|
||||
for i, revpair := range revpairs[:len(kvs)] {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
return nil, fmt.Errorf("rangeKeys: context cancelled: %w", ctx.Err())
|
||||
default:
|
||||
}
|
||||
revToBytes(revpair, revBytes)
|
||||
|
||||
Reference in New Issue
Block a user