Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8e77f41
docs: Design single-key CAS using MVCC versions
bootjp Nov 20, 2026
70b237c
kv: Add single-key compare-and-swap by MVCC version
bootjp Nov 20, 2026
193bbb6
kv: Bind MVCC CAS to replicated routing and test token retention
bootjp Nov 21, 2026
684220c
design: require replicated retirement before source cleanup
bootjp Dec 1, 2026
7e7cf4c
jepsen: require an execution witness for version CAS histories
bootjp Dec 1, 2026
44a53e3
Merge main and preserve CAS admission and forwarding safeguards
bootjp Dec 1, 2026
f204ddf
proof: specify visibility preservation under logical retirement
bootjp Dec 1, 2026
81e2ba7
adapter: own raw read scopes inside each handoff attempt
bootjp Dec 1, 2026
8270ac9
Merge main history checker fixes before stress validation
bootjp Dec 1, 2026
9a76110
test: exercise protected CAS with Jepsen and certify long ZSet histories
bootjp Dec 1, 2026
82b3a59
kv: replicate source retirement before physical reclamation
bootjp Dec 1, 2026
870d797
Merge reviewed Redis EXEC classification before validation
bootjp Dec 1, 2026
9f5bb9f
test: synchronize directory fixtures before interruptible close
bootjp Dec 1, 2026
31380e0
jepsen: verify guided ZSet histories within a shared search budget
bootjp Dec 1, 2026
1bb984d
kv: preserve unchanged versions across ownership return
bootjp Dec 1, 2026
81ce2ea
ci: pin verified Leiningen bootstrap
bootjp Dec 1, 2026
6fad887
sqs: log hidden query protocol failures server-side
bootjp Dec 1, 2026
358ce20
sqs: retry certified standard-send apply conflicts
bootjp Dec 1, 2026
9506656
jepsen: remove artificial cycles between commuting reads
bootjp Dec 1, 2026
448e584
Preserve protected TLS ownership and add dedicated CAS benchmarks
bootjp Dec 1, 2026
fa90874
Tighten benchmark warmup and drain boundaries
bootjp Dec 1, 2026
9bc1129
Match benchmark payloads and retry seeds across arms
bootjp Dec 1, 2026
6bb93bd
Constrain benchmark packages to the experiment CLI
bootjp Dec 1, 2026
96deee2
Capture fenced clock costs and recognize proven non-admission in tests
bootjp Dec 1, 2026
4fc8268
Make benchmark CPU accounting portable across Unix targets
bootjp Dec 1, 2026
2635a3d
Count timestamp and OCC rejections at their actual guards
bootjp Dec 1, 2026
ab5e0af
Align control calibration with the specified outcome budget
bootjp Dec 1, 2026
46cc33f
Preserve benchmark histories when meter collection fails
bootjp Dec 1, 2026
5bcb508
Merge main with verified bootstrap and TLS startup repairs
bootjp Dec 1, 2026
a25a245
Record dedicated-host CAS results and verified teardown
bootjp Dec 2, 2026
dc4b10b
Verify pinned launcher integrity and isolated installer fixtures
bootjp Dec 2, 2026
8833f8d
Merge launcher integrity repair and finalize benchmark evidence
bootjp Dec 2, 2026
53222ad
Avoid blocking committed reads on rejected entry persistence
bootjp Dec 2, 2026
21de688
Add fenced adaptive mismatch checks before CAS proposals
bootjp Dec 2, 2026
12407db
Confirm stale CAS tokens before write-only admission work
bootjp Dec 2, 2026
a78aac0
Record CAS apply verdicts independently of client callbacks
bootjp Dec 2, 2026
561be14
Bound contended CAS proposals with per-key admission
bootjp Dec 2, 2026
8e21598
Avoid cloning Raft progress during configuration capture
bootjp Dec 2, 2026
7196894
Capture SST snapshots from synced WAL checkpoints
bootjp Dec 2, 2026
d09c8dd
Batch queued protected follower appends
bootjp Dec 2, 2026
d32f120
Require caught-up voters between CAS benchmark windows
bootjp Dec 2, 2026
ef8f7cb
Capture owned snapshots without blocking the Raft owner
bootjp Dec 2, 2026
7b50a4f
Merge main while preserving CAS and record GC compatibility
bootjp Dec 2, 2026
3367d43
Enforce snapshot durability and lifecycle fences
bootjp Dec 2, 2026
1c08716
Preserve offline TSO preparation with stable store locks
bootjp Dec 2, 2026
f91082d
Reduce protected ReadIndex dispatch amplification
bootjp Dec 3, 2026
a86a849
Amortize protected data proposal WAL writes
bootjp Dec 3, 2026
c5a7a23
Avoid resetting append progress on heartbeat overload
bootjp Dec 3, 2026
2fde424
Avoid syncing private owned snapshot scratch files
bootjp Dec 3, 2026
65d4bf5
Preserve acknowledged Append progress on delayed send failure
bootjp Dec 3, 2026
d797ee4
Validate Append feedback ranges and protected ACK admission
bootjp Dec 3, 2026
35a5aeb
Share bounded follower WAL saves for read-dependent 1PC appends
bootjp Dec 3, 2026
84d1a08
Document revocation-faithful follower recovery validation
bootjp Dec 3, 2026
19a24f2
Verify follower catch-up without bypassing session revocation
bootjp Dec 3, 2026
148e459
Record complete follower regression and classifier cost evidence
bootjp Dec 3, 2026
c386826
Wait for completed configuration publication in self-removal tests
bootjp Dec 3, 2026
9a5db83
Merge main while preserving owned snapshot lifecycle
bootjp Dec 3, 2026
add58a6
Cover snapshot retry metadata in ingress feedback tests
bootjp Dec 3, 2026
137ca98
Document fenced read floor error identity boundaries
bootjp Dec 3, 2026
74199fc
Synchronize membership tests and bounded preflight recovery
bootjp Dec 3, 2026
e934e1a
Preserve fenced transfer errors and unresolved reuse outcomes
bootjp Dec 3, 2026
15a9c7c
Document synchronous Raft catch-up byte window
bootjp Dec 3, 2026
a7993de
Bound synchronous Raft catch-up refills
bootjp Dec 3, 2026
389549e
Handle read-fence leadership loss in sequence tests
bootjp Dec 3, 2026
f82cbac
Isolate synchronous native large-value race tests
bootjp Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
shard:
name: test shard (${{ matrix.shard }})
env:
RAFT_NATIVE_MEMORY_TESTS: '^(TestMigrationQuorumCommitFollowsForcedLeadershipTransfer|TestMigrationQuorumPartitionAcceptance|TestEnginePipelineNativeEncryptedLargeQuorumSnapshotRestart)$'
RAFT_NATIVE_MEMORY_TESTS: '^(TestMigrationQuorumCommitFollowsForcedLeadershipTransfer|TestMigrationQuorumPartitionAcceptance|TestEnginePipelineNativeEncryptedLargeQuorumSnapshotRestart|TestSyncInflightMessageTargets)$'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
run: go test -race -timeout=30m ./adapter -run "$RAFT_NATIVE_MEMORY_TESTS"
- name: Run encrypted native large-value race acceptance
if: matrix.shard == 'raft-crypto'
run: go test -race -timeout=30m ./internal/raftengine/etcd -run "$RAFT_NATIVE_MEMORY_TESTS"
run: go test -race -v -timeout=30m ./internal/raftengine/etcd -run "$RAFT_NATIVE_MEMORY_TESTS"
# Branch protection requires the "test (ubuntu-latest)" check, so this
# job keeps that name and passes only when every shard passed.
test:
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/jepsen-test-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
SPLIT_MEMBERSHIP_FAULT: none
run: LEIN="$HOME/lein" bash scripts/jepsen-split-preflight.sh --online-member-change
- name: Launch demo cluster
if: matrix.workload != 'unit' && matrix.workload != 'split-membership' && !startsWith(matrix.workload, 'filesystem-') && !startsWith(matrix.workload, 'sqs-') && matrix.workload != 'sqlite'
if: matrix.workload != 'unit' && matrix.workload != 'split-membership' && matrix.workload != 'grpc-version-cas' && !startsWith(matrix.workload, 'filesystem-') && !startsWith(matrix.workload, 'sqs-') && matrix.workload != 'sqlite'
run: |
set -euo pipefail
nohup /tmp/elastickv-demo > /tmp/elastickv-demo.log 2>&1 &
Expand Down Expand Up @@ -351,7 +351,7 @@ jobs:
--sqs-ports 63501,63502,63503 --host 127.0.0.1 \
"${EXTRA_ARGS[@]}"
- name: Run public gRPC Elle workload
if: startsWith(matrix.workload, 'grpc-')
if: matrix.workload == 'grpc-raw' || matrix.workload == 'grpc-transactional'
working-directory: jepsen
env:
GRPC_TIME_LIMIT: ${{ inputs.time-limit || '300' }}
Expand All @@ -372,6 +372,15 @@ jobs:
--grpc-ports 50051,50052,50053 --grpc-api "${WORKLOAD#grpc-}" \
--time-limit "$GRPC_TIME_LIMIT" --rate "$GRPC_RATE" \
--concurrency 6 --key-count "$S3_KEY_COUNT" --max-writes-per-key "$S3_MAX_OPS_PER_KEY"
- name: Run protected three-voter CAS Jepsen with follower restart
if: matrix.workload == 'grpc-version-cas'
timeout-minutes: 40
env:
ELASTICKV_CAS_JEPSEN_SECONDS: ${{ inputs.time-limit || '300' }}
ELASTICKV_CAS_JEPSEN_CLIENT: /tmp/jepsen-grpc-client
run: |
export PATH="$HOME:$PATH"
go test ./internal/server -run '^TestVersionCASJepsenStress$' -count=1 -v -timeout=35m
- name: Launch filesystem cluster
if: startsWith(matrix.workload, 'filesystem-') || matrix.workload == 'sqlite'
# Mirrors the cluster in jepsen-test.yml: every node mounts the shared
Expand Down
44 changes: 35 additions & 9 deletions .github/workflows/tla-check.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
name: TLA+ model check

# Runs `make tla-check` on PRs (and pushes to main) that touch the
# subsystems modelled by the spec or the spec / tooling themselves.
# Per docs/design/2026_05_28_implemented_tla_safety_spec.md §7.3.
#
# The job runs both MCHLC.cfg (correct design — expected PASS) and
# MCHLC_gap.cfg (preconditions disabled — expected FAIL with the HLC-4
# counterexample); the Makefile target greps for the specific HLC-4
# violation string so the gap evidence is validated, not just the exit
# code.
# Checks the Lean proofs and bounded TLC models for the affected subsystems.

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'tla/**'
- 'lean/**'
- 'Makefile'
- 'kv/hlc*.go'
- 'kv/tso*.go'
- 'kv/coordinator.go'
- 'kv/sharded_coordinator.go'
- 'kv/transaction.go'
- 'kv/fsm.go'
- 'kv/fsm_cas.go'
- 'kv/fsm_migration_cleanup.go'
- 'kv/migration_version_identity.go'
- 'kv/version_cas_*.go'
- 'kv/fsm_migration_serving.go'
- 'kv/lock_resolver.go'
- 'store/mvcc_store.go'
- 'store/lsm_store.go'
- 'store/migration_cleanup.go'
- 'store/raft_entry*.go'
- 'store/migration_online*.go'
- 'store/migration_capture*.go'
- 'adapter/split_job*.go'
Expand All @@ -37,17 +36,24 @@ on:
branches: [main]
paths:
- 'tla/**'
- 'lean/**'
- 'Makefile'
- 'kv/hlc*.go'
- 'kv/tso*.go'
- 'kv/coordinator.go'
- 'kv/sharded_coordinator.go'
- 'kv/transaction.go'
- 'kv/fsm.go'
- 'kv/fsm_cas.go'
- 'kv/fsm_migration_cleanup.go'
- 'kv/migration_version_identity.go'
- 'kv/version_cas_*.go'
- 'kv/fsm_migration_serving.go'
- 'kv/lock_resolver.go'
- 'store/mvcc_store.go'
- 'store/lsm_store.go'
- 'store/migration_cleanup.go'
- 'store/raft_entry*.go'
- 'store/migration_online*.go'
- 'store/migration_capture*.go'
- 'adapter/split_job*.go'
Expand Down Expand Up @@ -100,3 +106,23 @@ jobs:

- name: Run make tla-check
run: make tla-check

lean-check:
name: lean-check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out
uses: actions/checkout@v7

- name: Install pinned Lean
run: |
version="$(cut -d: -f2 lean/lean-toolchain)"
release="lean-${version#v}-linux"
archive="$RUNNER_TEMP/$release.tar.zst"
curl -fsSL "https://github.com/leanprover/lean4/releases/download/$version/$release.tar.zst" -o "$archive"
tar --zstd -xf "$archive" -C "$RUNNER_TEMP"
printf '%s\n' "$RUNNER_TEMP/$release/bin" >> "$GITHUB_PATH"

- name: Run make lean-check
run: make lean-check
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.PHONY: build test lean-check

LEAN ?= lean

build:
go build ./...

test:
go test -v -race ./...

lean-check:
cd lean && for proof in *.lean; do lean -DwarningAsError=true "$$proof" || exit 1; done
cd lean && for proof in *.lean; do "$(LEAN)" -DwarningAsError=true "$$proof" || exit 1; done
sh lean/adapter/check.sh

run:
Expand Down Expand Up @@ -36,7 +38,7 @@ TLA_SHA256 := 936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88
TLA_URL := https://github.com/tlaplus/tlaplus/releases/download/$(TLA_VERSION)/tla2tools.jar
TLA_LIB := ../lib

.PHONY: tla-check tla-tools
.PHONY: tla-check tla-cas-check tla-tools

tla-tools:
@mkdir -p $(dir $(TLA_JAR))
Expand Down Expand Up @@ -72,7 +74,10 @@ tla-tools:
trap - EXIT HUP INT TERM; \
echo "tla2tools.jar ready at $(TLA_JAR) (SHA-256 $(TLA_SHA256))"

tla-check: tla-tools
tla-cas-check: tla-tools
@bash tla/cas/check.sh "$(abspath $(TLA_JAR))"

tla-check: tla-cas-check
@# Per-module orchestration lives in scripts/tla-check.sh so adding
@# M3..M5 only needs an entry in that script's TLA_MODULES array
@# and a `case` line for the gap-invariant string. The script does
Expand Down
3 changes: 3 additions & 0 deletions adapter/distribution_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ func (s *DistributionServer) promoteSplitJobTargetAndComplete(ctx context.Contex
if client == nil {
return errors.New("split promotion client is nil")
}
if err := s.prepareSplitVersionAdoption(ctx, job, client); err != nil {
return err
}
if err := promoteSplitJobTarget(ctx, client, job); err != nil {
return errors.WithStack(err)
}
Expand Down
2 changes: 1 addition & 1 deletion adapter/distribution_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ func coordinatorStubMutation(elem *kv.Elem[kv.OP], commitTS uint64) (*store.KVPa
Op: store.OpTypeDelete,
Key: distribution.CloneBytes(elem.Key),
}, nil
case kv.DelPrefix:
case kv.DelPrefix, kv.CompareAndSwap:
return nil, kv.ErrInvalidRequest
default:
return nil, kv.ErrInvalidRequest
Expand Down
2 changes: 1 addition & 1 deletion adapter/dynamodb_item_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (d *DynamoDBServer) reuseMutationMatches(ctx context.Context, elem *kv.Elem
return true, nil
}
return false, errors.Wrap(err, "read reuse tombstone")
case kv.DelPrefix:
case kv.DelPrefix, kv.CompareAndSwap:
return false, nil
}
return false, nil
Expand Down
99 changes: 99 additions & 0 deletions adapter/fenced_floor_proxy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package adapter

import (
"context"
"fmt"
"sync/atomic"
"testing"

"github.com/bootjp/elastickv/distribution"
"github.com/bootjp/elastickv/internal/raftengine"
"github.com/bootjp/elastickv/kv"
pb "github.com/bootjp/elastickv/proto"
"github.com/bootjp/elastickv/store"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

type fencedFloorReadEngine struct {
localCompactionReadEngine
err error
reads atomic.Int32
}

func (e *fencedFloorReadEngine) LinearizableRead(context.Context) (uint64, error) {
e.reads.Add(1)
return 0, e.err
}

func fencedFloorShardStore(st store.MVCCStore, engine *fencedFloorReadEngine) *kv.ShardStore {
routes := distribution.NewEngine()
routes.UpdateRoute(nil, nil, 1)
return kv.NewShardStore(routes, map[uint64]*kv.ShardGroup{1: {Store: st, Engine: engine}})
}

type fencedFloorTargetCoordinator struct {
*verifyHookCoordinator
mutations atomic.Int32
}

func (c *fencedFloorTargetCoordinator) Dispatch(ctx context.Context, req *kv.OperationGroup[kv.OP]) (*kv.CoordinateResponse, error) {
if !isDynamoSnapshotSealRequest(req) {
c.mutations.Add(1)
}
return c.localAdapterCoordinator.Dispatch(ctx, req)
}

func dialFencedFloorProxy(t *testing.T, targetStore store.MVCCStore, coord kv.Coordinator) *redisWireClient {
t.Helper()
target := startRedisWireServer(t, targetStore, coord, newRedisWireTestGate(t), WithOnePhaseTxnDedup(true))
st := newRedisWireStore(t)
follower := newLocalAdapterCoordinator(st)
follower.leaderSet, follower.leader, follower.raftLeader = true, false, "target"
proxy := startRedisWireServer(t, st, follower, newRedisWireTestGate(t), func(s *RedisServer) {
s.leaderRedis = map[string]string{"target": target.listen.Addr().String()}
})
return dialRedisWire(t, proxy)
}

func TestFencedFloorRedisProxyTransfer(t *testing.T) {
base := newRedisWireStore(t)
engine := &fencedFloorReadEngine{err: raftengine.ErrLeadershipTransferInProgress}
shards := fencedFloorShardStore(base, engine)
coord := &fencedFloorTargetCoordinator{verifyHookCoordinator: newVerifyHookCoordinator(base)}
client := dialFencedFloorProxy(t, shards, coord)
client.send(t, []string{cmdMulti}, []string{cmdRPush, "a", "1"}, []string{cmdRPush, "b", "2"},
[]string{cmdRPush, "c", "3"}, []string{cmdExec}, []string{cmdPing})
client.want(t, "+OK\r\n+QUEUED\r\n+QUEUED\r\n+QUEUED\r\n")
frame, err := client.r.ReadString('\n')
require.NoError(t, err)
coord.mu.Lock()
leases := coord.leaseCalls
coord.mu.Unlock()
require.Positive(t, leases, "the target must pass the initial lease check")
require.EqualValues(t, 1, engine.reads.Load(), "the target must reach the actual floor fence")
require.Zero(t, coord.mutations.Load())
require.Equal(t, "-"+redisNotLeaderReply+"\r\n", frame)
client.want(t, "+PONG\r\n")
}

func TestFencedFloorRedisProxyMixedExec(t *testing.T) {
st := newRedisWireStore(t)
client := dialFencedFloorProxy(t, st, newLocalAdapterCoordinator(st))
client.send(t, []string{cmdMulti}, []string{cmdSet, "a", "v"}, []string{cmdRPush, "a", "x"},
[]string{cmdGet, "a"}, []string{cmdExec}, []string{cmdPing})
client.want(t, "+OK\r\n+QUEUED\r\n+QUEUED\r\n+QUEUED\r\n*3\r\n+OK\r\n-"+wrongTypeMessage+"\r\n$1\r\nv\r\n+PONG\r\n")
}

func TestFencedFloorRawGroupWatermarkInternalDeadline(t *testing.T) {
engine := &fencedFloorReadEngine{err: fmt.Errorf("synthetic-key: %w", context.DeadlineExceeded)}
shards := fencedFloorShardStore(newRedisWireStore(t), engine)
ctx := t.Context()
reply, err := NewGRPCServer(shards, nil).RawLatestCommitTS(ctx, &pb.RawLatestCommitTSRequest{GroupId: 1})
require.NoError(t, ctx.Err())
require.EqualValues(t, 1, engine.reads.Load())
require.Nil(t, reply)
require.Equal(t, codes.Unavailable, status.Code(err))
require.NotContains(t, status.Convert(err).Message(), "synthetic-key")
}
Loading
Loading