diff --git a/seaweed-block/core/storage/parallelwal/native_submitter.go b/seaweed-block/core/storage/parallelwal/native_submitter.go index d0eb06ad0d..321ca664a4 100644 --- a/seaweed-block/core/storage/parallelwal/native_submitter.go +++ b/seaweed-block/core/storage/parallelwal/native_submitter.go @@ -36,6 +36,7 @@ type nativeWALSubmitter struct { stop chan struct{} done chan struct{} closeOnce sync.Once + nextLane int mu sync.Mutex stats NativeIOStats @@ -137,10 +138,13 @@ func (submitter *nativeWALSubmitter) takeRound() ([]nativeWALBatch, error) { maxOperations = len(submitter.store.lanes) } batches := make([]nativeWALBatch, 0, maxOperations) - for _, lane := range submitter.store.lanes { + startLane := submitter.nextLane + for visited := 0; visited < len(submitter.store.lanes); visited++ { if len(batches) == maxOperations { break } + laneID := (startLane + visited) % len(submitter.store.lanes) + lane := submitter.store.lanes[laneID] batch, ok, err := submitter.takeLaneBatch(lane) if err != nil { if len(batch.requests) != 0 { @@ -150,6 +154,7 @@ func (submitter *nativeWALSubmitter) takeRound() ([]nativeWALBatch, error) { } if ok { batches = append(batches, batch) + submitter.nextLane = (laneID + 1) % len(submitter.store.lanes) } } return batches, nil diff --git a/seaweed-block/core/storage/parallelwal/native_submitter_linux_amd64_test.go b/seaweed-block/core/storage/parallelwal/native_submitter_linux_amd64_test.go index 85cc3691a7..92e289ff41 100644 --- a/seaweed-block/core/storage/parallelwal/native_submitter_linux_amd64_test.go +++ b/seaweed-block/core/storage/parallelwal/native_submitter_linux_amd64_test.go @@ -69,3 +69,30 @@ func TestIOUringOwnerBatchesAcrossLanesAndRecoversPortably(t *testing.T) { } } } + +func TestIOUringOwnerRotatesAcrossLanesAtDepthOne(t *testing.T) { + path := filepath.Join(t.TempDir(), "depth-one.bin") + cfg := testConfig() + cfg.QueueDepth = 1 + cfg.Execution = ExecutionIOUring + store, err := CreateStoreWithConfig(path, cfg) + if err != nil { + t.Fatal(err) + } + defer store.Close() + + blocks := [][]byte{ + testBlock(0x51, cfg.BlockSize), + testBlock(0x52, cfg.BlockSize), + testBlock(0x53, cfg.BlockSize), + testBlock(0x54, cfg.BlockSize), + } + if _, err := store.WriteBatch(0, blocks); err != nil { + t.Fatal(err) + } + stats := store.NativeIOStats() + if stats.QueueDepth != 1 || stats.SubmissionRounds != 4 || + stats.SQEs != 4 || stats.CompletionCount != 4 { + t.Fatalf("depth-one native stats=%+v", stats) + } +}