Skip to content

Commit 6946814

Browse files
authored
Merge pull request #503 from bootjp/feat/read-skew-fix
fix: clarify FSM comment, fix gci formatting, pin golangci-lint version
2 parents 6eb2e2e + 4314c84 commit 6946814

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
uses: reviewdog/action-golangci-lint@v2
2323
with:
2424
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
golangci_lint_version: "v2.9.0"
2526
level: warning
2627
golangci_lint_flags: "--config=.golangci.yaml"
2728
filter_mode: nofilter

kv/fsm.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,11 @@ func (f *kvFSM) handlePrepareRequest(ctx context.Context, r *pb.Request) error {
320320
}
321321

322322
// handleOnePhaseTxnRequest applies a single-shard transaction atomically.
323-
// Both write-write and read-write conflicts are checked: the read set carried
324-
// in r.ReadKeys is validated alongside the mutation keys inside
325-
// ApplyMutations under the store's apply lock.
323+
// Write-write conflicts are always checked under the store's apply lock.
324+
// r.ReadKeys is passed through to ApplyMutations for read-write conflict
325+
// detection; for single-shard transactions it is typically nil because the
326+
// adapter validates the read set pre-Raft (see kv/coordinator.go), while
327+
// multi-shard PREPARE requests carry per-shard read keys.
326328
func (f *kvFSM) handleOnePhaseTxnRequest(ctx context.Context, r *pb.Request, commitTS uint64) error {
327329
meta, muts, err := extractTxnMeta(r.Mutations)
328330
if err != nil {

kv/sharded_coordinator_txn_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
"sync"
77
"testing"
88

9-
"github.com/stretchr/testify/require"
10-
"google.golang.org/protobuf/proto"
11-
129
"github.com/bootjp/elastickv/distribution"
1310
"github.com/bootjp/elastickv/internal/raftengine"
1411
pb "github.com/bootjp/elastickv/proto"
1512
"github.com/bootjp/elastickv/store"
13+
"github.com/stretchr/testify/require"
14+
"google.golang.org/protobuf/proto"
1615
)
1716

1817
type recordingTransactional struct {
@@ -383,11 +382,11 @@ type noopEngine struct{}
383382
func (noopEngine) Propose(_ context.Context, _ []byte) (*raftengine.ProposalResult, error) {
384383
return &raftengine.ProposalResult{}, nil
385384
}
386-
func (noopEngine) State() raftengine.State { return raftengine.StateLeader }
387-
func (noopEngine) Leader() raftengine.LeaderInfo { return raftengine.LeaderInfo{} }
388-
func (noopEngine) VerifyLeader(_ context.Context) error { return nil }
389-
func (noopEngine) LinearizableRead(_ context.Context) (uint64, error) { return 0, nil }
390-
func (noopEngine) Status() raftengine.Status { return raftengine.Status{} }
385+
func (noopEngine) State() raftengine.State { return raftengine.StateLeader }
386+
func (noopEngine) Leader() raftengine.LeaderInfo { return raftengine.LeaderInfo{} }
387+
func (noopEngine) VerifyLeader(_ context.Context) error { return nil }
388+
func (noopEngine) LinearizableRead(_ context.Context) (uint64, error) { return 0, nil }
389+
func (noopEngine) Status() raftengine.Status { return raftengine.Status{} }
391390
func (noopEngine) Configuration(_ context.Context) (raftengine.Configuration, error) {
392391
return raftengine.Configuration{}, nil
393392
}
@@ -498,7 +497,7 @@ func TestShardedCoordinatorDispatchTxn_ReadKeysRoutedToPrepareByShard(t *testing
498497

499498
engine := distribution.NewEngine()
500499
engine.UpdateRoute([]byte("a"), []byte("m"), 1) // shard 1: a-m
501-
engine.UpdateRoute([]byte("m"), nil, 2) // shard 2: m+
500+
engine.UpdateRoute([]byte("m"), nil, 2) // shard 2: m+
502501

503502
g1Txn := &recordingTransactional{}
504503
g2Txn := &recordingTransactional{}

0 commit comments

Comments
 (0)