Skip to content

Commit

Permalink
Fix data race (#18536)
Browse files Browse the repository at this point in the history
fix data race

Approved by: @LeftHandCold
  • Loading branch information
XuPeng-SH committed Sep 4, 2024
1 parent ad803bc commit 97976e8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
33 changes: 33 additions & 0 deletions pkg/vm/engine/tae/db/test/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9298,3 +9298,36 @@ func TestDeleteWithObjectStats(t *testing.T) {

// tae.CheckRowsByScan(10, true)
}

func TestFillBlockTombstonesPersistedAobj(t *testing.T) {
ctx := context.Background()

opts := config.WithLongScanAndCKPOpts(nil)
tae := testutil.NewTestEngine(ctx, ModuleName, t, opts)
defer tae.Close()
schema := catalog.MockSchemaAll(1, 0)
schema.BlockMaxRows = 1
schema.ObjectMaxBlocks = 5
tae.BindSchema(schema)
bat := catalog.MockBatch(schema, 1)
defer bat.Close()
tae.CreateRelAndAppend(bat, true)
tae.DeleteAll(true)

txn, rel := tae.GetRelation()
atombstone := testutil.GetOneTombstoneMeta(rel)
dataObj := testutil.GetOneBlockMeta(rel)
assert.NoError(t, txn.Commit(ctx))
tae.CompactBlocks(true)

txn, _ = tae.GetRelation()
deletes := &nulls.Nulls{}
atombstone.GetObjectData().FillBlockTombstones(
ctx,
txn,
types.NewBlockidWithObjectID(dataObj.ID(), 0),
&deletes,
common.DebugAllocator)
assert.NoError(t, txn.Commit(ctx))
assert.Equal(t, 1, deletes.Count())
}
7 changes: 5 additions & 2 deletions pkg/vm/engine/tae/tables/pnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,16 @@ func (node *persistedNode) FillBlockTombstones(
}
}()
var commitTSs []types.TS
var commitTSVec containers.Vector
if node.object.meta.Load().IsAppendable() {
commitTSVec, err := node.object.LoadPersistedCommitTS(uint16(tombstoneBlkID))
commitTSVec, err = node.object.LoadPersistedCommitTS(uint16(tombstoneBlkID))
if err != nil {
return err
}
commitTSs = vector.MustFixedCol[types.TS](commitTSVec.GetDownstreamVector())
commitTSVec.Close()
}
if commitTSVec != nil {
defer commitTSVec.Close()
}
rowIDs := vector.MustFixedCol[types.Rowid](vecs[0].GetDownstreamVector())
// TODO: biselect, check visibility
Expand Down

0 comments on commit 97976e8

Please sign in to comment.