Skip to content

Commit

Permalink
table: acquire active write block on compaction
Browse files Browse the repository at this point in the history
Otherwise, compaction races with snapshots.
  • Loading branch information
asubiotto committed Oct 10, 2023
1 parent 35a6479 commit 3c51e6e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,12 @@ func (t *Table) externalParquetCompaction(writer io.Writer) func(compact []*part
// compactParts will compact the given parts into a Parquet file written to w.
// It returns the size in bytes of the compacted parts.
func (t *Table) compactParts(w io.Writer, compact []*parts.Part) (int64, error) {
block, done, err := t.ActiveWriteBlock()
if err != nil {
return 0, err
}
defer done()

bufs := []dynparquet.DynamicRowGroup{}
var size int64
for _, part := range compact {
Expand All @@ -1128,7 +1134,7 @@ func (t *Table) compactParts(w io.Writer, compact []*parts.Part) (int64, error)
return 0, err
}
err = func() error {
p, err := t.active.rowWriter(w, merged.DynamicColumns())
p, err := block.rowWriter(w, merged.DynamicColumns())
if err != nil {
return err
}
Expand Down

0 comments on commit 3c51e6e

Please sign in to comment.