Repository navigation
test: verify DynamoDB snapshot seals with real Raft #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
69f2d93
test: verify DynamoDB snapshot seals with real Raft
bootjp 2205e67
fix: isolate seal histories and retry forwarded locks
bootjp 8db0155
fix: normalize all DynamoDB forwarded write failures
bootjp f432933
docs: retain encrypted seal acceptance failures
bootjp a0f5506
test: distinguish snapshot seals from global timestamp fences
bootjp f1d02b0
Merge branch 'main' into feature/dynamodb-snapshot-seal-acceptance
bootjp dcd7bf9
Merge reviewed checkpoint fixes into seal acceptance
bootjp 4c51221
Merge reviewed encryption budget into seal acceptance
bootjp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| package adapter | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "sync/atomic" | ||
| "testing" | ||
|
|
||
| "github.com/bootjp/elastickv/kv" | ||
| "github.com/bootjp/elastickv/store" | ||
| "github.com/cockroachdb/errors" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| type sealBenchmarkCoordinator struct { | ||
| kv.Coordinator | ||
| seals atomic.Uint64 | ||
| conflicts atomic.Uint64 | ||
| } | ||
|
|
||
| func (c *sealBenchmarkCoordinator) Dispatch(ctx context.Context, req *kv.OperationGroup[kv.OP]) (*kv.CoordinateResponse, error) { | ||
| if isDynamoSnapshotSealRequest(req) { | ||
| c.seals.Add(1) | ||
| } | ||
| resp, err := c.Coordinator.Dispatch(ctx, req) | ||
| if errors.Is(err, store.ErrWriteConflict) { | ||
| c.conflicts.Add(1) | ||
| } | ||
| return resp, err | ||
| } | ||
|
|
||
| // A single durable Raft voter isolates the extra seal/OCC cost. This is not a | ||
| // networked quorum or a production throughput claim. Separate frontends avoid | ||
| // serializing the workload with a shared server's item-lock stripes. | ||
| func BenchmarkDynamoDBSnapshotSealRealRaft(b *testing.B) { | ||
| for _, mode := range []string{"independent", "hot_item", "collision"} { | ||
| b.Run(mode, func(b *testing.B) { | ||
| ctx := context.Background() | ||
| st := store.NewMVCCStore() | ||
| defer st.Close() | ||
| server, _, stop := sealRaftRestartableServer(b, b.TempDir(), st) | ||
| defer stop() | ||
| schema := dedupItemTable() | ||
| require.NoError(b, server.createTableWithRetry(ctx, schema.TableName, schema)) | ||
| keys := sealBenchmarkKeys(b, schema, mode) | ||
| for _, key := range keys { | ||
| _, err := server.putItemWithRetry(ctx, putItemInput{ | ||
| TableName: schema.TableName, Item: map[string]attributeValue{"pk": newStringAttributeValue(key)}, | ||
| }) | ||
| require.NoError(b, err) | ||
| } | ||
| coord := &sealBenchmarkCoordinator{Coordinator: server.coordinator} | ||
| var worker atomic.Uint64 | ||
| b.ReportAllocs() | ||
| b.ResetTimer() | ||
| b.RunParallel(func(pb *testing.PB) { | ||
| local := NewDynamoDBServer(nil, st, coord) | ||
| key := keys[(worker.Add(1)-1)%uint64(len(keys))] | ||
| in := putItemInput{TableName: schema.TableName, Item: map[string]attributeValue{ | ||
| "pk": newStringAttributeValue(key), "value": newStringAttributeValue("constant-size replacement"), | ||
| }} | ||
| for pb.Next() { | ||
| if _, err := local.putItemWithRetry(ctx, in); err != nil { | ||
| b.Error(err) | ||
| return | ||
| } | ||
| } | ||
| }) | ||
| b.StopTimer() | ||
| b.ReportMetric(float64(coord.seals.Load())/float64(b.N), "seals/op") | ||
| b.ReportMetric(float64(coord.conflicts.Load())/float64(b.N), "conflicts/op") | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func sealBenchmarkKeys(b *testing.B, schema *dynamoTableSchema, mode string) []string { | ||
| b.Helper() | ||
| if mode == "hot_item" { | ||
| return []string{"hot"} | ||
| } | ||
| const count = 4 | ||
| buckets := make(map[string][]string) | ||
| independent := make([]string, 0, count) | ||
| for i := range 1 << 20 { | ||
| key := fmt.Sprintf("seal-bench-%d", i) | ||
| item, err := schema.itemKeyFromAttributes(map[string]attributeValue{"pk": newStringAttributeValue(key)}) | ||
| require.NoError(b, err) | ||
| seal := string(dynamoItemSnapshotSealKey(schema.TableName, schema.Generation, item)) | ||
| if mode == "independent" && len(buckets[seal]) == 0 { | ||
| independent = append(independent, key) | ||
| if len(independent) == count { | ||
| return independent | ||
| } | ||
| } | ||
| buckets[seal] = append(buckets[seal], key) | ||
| if mode == "collision" && len(buckets[seal]) == count { | ||
| return buckets[seal] | ||
| } | ||
| } | ||
| b.Fatal("could not construct seal bucket fixture") | ||
| return nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.