Repository: polarsignals/frostdb (go)

Issue:
SeekToRow skips rows during compaction
```
thor@thors-MacBook-Pro frostdb % go test -v -run XXX -bench Writers
goos: darwin
goarch: arm64
pkg: github.com/polarsignals/frostdb
Benchmark_Table_Insert_1000Rows_10Iters_10Writers
    table_test.go:427:
        	Error Trace:	table_test.go:427
        	            				table_test.go:307
        	Error:      	Not equal:
        	            	expected: 100000
        	            	actual  : 55634
        	Test:       	Benchmark_Table_Insert_1000Rows_10Iters_10Writers
--- FAIL: Benchmark_Table_Insert_1000Rows_10Iters_10Writers
```

After a git bisect it appears that https://github.com/polarsignals/frostdb/commit/017d5f6d9baff694ad147cdd15071feb367f71a0 is the offending commit @asubiotto 

Pull request description:
frostdb: remove unnecessary SeekToRow call during compaction
This call would simply verify that we placed the cursor at the desired row. However, this SeekToRow is causing correctness issues although it's supposed to be a noop.

Fixes #294 

Patch:
diff --git a/compaction.go b/compaction.go
index 45b1674..96b9989 100644
--- a/compaction.go
+++ b/compaction.go
@@ -566,9 +566,6 @@ func compactLevel0IntoLevel1(
 
 		for {
 			var mergedBytes bytes.Buffer
-			if err := rows.SeekToRow(int64(cursor)); err != nil {
-				return err
-			}
 			n, err := t.writeRows(&mergedBytes, rows, merged.DynamicColumns(), estimatedRowsPerPart)
 			if err != nil {
 				return err


Test patch:
diff --git a/compaction_test.go b/compaction_test.go
index 5852e59..d762fbf 100644
--- a/compaction_test.go
+++ b/compaction_test.go
@@ -216,6 +216,46 @@ func TestCompaction(t *testing.T) {
 				},
 			},
 		},
+		{
+			name: "MultipleL0ToL1",
+			inserts: []int64{
+				acc, 1, 2, 3, flushAcc,
+				acc, 4, 5, 6, flushAcc,
+				recordGranuleSizeCommand,
+				acc, 7, 8, 9, flushAcc,
+				setRecordedGranuleSizeCommand,
+				compactCommand,
+			},
+			expected: []expectedGranule{
+				{
+					[]expectedPart{
+						{
+							numRowGroups:    2,
+							compactionLevel: compactionLevel1,
+							data:            []int64{1, 2, 3, 4},
+						},
+					},
+				},
+				{
+					[]expectedPart{
+						{
+							numRowGroups:    2,
+							compactionLevel: compactionLevel1,
+							data:            []int64{5, 6, 7, 8},
+						},
+					},
+				},
+				{
+					[]expectedPart{
+						{
+							numRowGroups:    1,
+							compactionLevel: compactionLevel1,
+							data:            []int64{9},
+						},
+					},
+				},
+			},
+		},
 	}
 
 	numParts := func(g *Granule) int {
diff --git a/table_test.go b/table_test.go
index b0a5241..31140fb 100644
--- a/table_test.go
+++ b/table_test.go
@@ -334,6 +334,7 @@ func benchmarkTableInserts(b *testing.B, rows, iterations, writers int) {
 		WithStoragePath(dir),
 	)
 	require.NoError(b, err)
+	defer c.Close()
 
 	db, err := c.DB(context.Background(), "test")
 	require.NoError(b, err)