Skip to content

Commit

Permalink
fix delete page error and some typos (#17087)
Browse files Browse the repository at this point in the history
fix delete page error and some typos.
In previous code, TaskMergeTransferPageLengthGauge will not sub cnt after rollback.

Approved by: @XuPeng-SH
  • Loading branch information
w-zr authored Jun 24, 2024
1 parent 8eb9e70 commit 9f1c2df
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkg/vm/engine/tae/common/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (item *PinnedItem[T]) Item() T { return item.Val }
type IRef interface {
RefCount() int64
// RefIfHasRef increment refcnt if existing cnt > 0 and return true,
// return false if cnt is zero. Note: the udpate is atomic
// return false if cnt is zero. Note: the update is atomic
RefIfHasRef() bool
Ref()
Unref()
Expand Down
4 changes: 2 additions & 2 deletions pkg/vm/engine/tae/db/test/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4305,7 +4305,7 @@ func TestCollectDelete(t *testing.T) {
assert.NoError(t, err)
assert.NoError(t, txn.Commit(context.Background()))

blkdata.GCInMemeoryDeletesByTSForTest(p3)
blkdata.GCInMemoryDeletesByTSForTest(p3)

batch, _, err = blkdata.CollectDeleteInRange(context.Background(), p1.Next(), p3, true, common.DefaultAllocator)
assert.NoError(t, err)
Expand Down Expand Up @@ -8088,7 +8088,7 @@ func TestGCInMemoryDeletesByTS(t *testing.T) {
assert.NoError(t, err)
assert.NoError(t, txn.Commit(context.Background()))

blkData.GCInMemeoryDeletesByTSForTest(ts)
blkData.GCInMemoryDeletesByTSForTest(ts)
}
i++
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/engine/tae/iface/data/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ type Object interface {

Init() error
TryUpgrade() error
GCInMemeoryDeletesByTSForTest(types.TS)
GCInMemoryDeletesByTSForTest(types.TS)
UpgradeAllDeleteChain()
CollectAppendInRange(start, end types.TS, withAborted bool, mp *mpool.MPool) (*containers.BatchWithVersion, error)
CollectDeleteInRange(ctx context.Context, start, end types.TS, withAborted bool, mp *mpool.MPool) (*containers.Batch, *bitmap.Bitmap, error)
Expand Down
14 changes: 4 additions & 10 deletions pkg/vm/engine/tae/model/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package model

import (
v2 "github.com/matrixorigin/matrixone/pkg/util/metric/v2"
"sync"
"time"

"github.com/matrixorigin/matrixone/pkg/common/moerr"
v2 "github.com/matrixorigin/matrixone/pkg/util/metric/v2"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common"
)

Expand Down Expand Up @@ -116,22 +116,16 @@ func (table *TransferTable[T]) AddPage(page T) (dup bool) {
return
}

func (table *TransferTable[T]) DeletePage(id *common.ID) (deleted bool) {
func (table *TransferTable[T]) DeletePage(id *common.ID) {
table.Lock()
defer table.Unlock()
if _, deleted = table.pages[*id]; !deleted {
if _, ok := table.pages[*id]; !ok {
return
}
cnt := table.pages[*id].Val.Length()
delete(table.pages, *id)

// to pass ut
if len(table.pages) == 0 || table.pages[*id] == nil {
return
}

cnt := table.pages[*id].Val.Length()
v2.TaskMergeTransferPageLengthGauge.Sub(float64(cnt))
return
}

func (table *TransferTable[T]) Close() {
Expand Down
11 changes: 5 additions & 6 deletions pkg/vm/engine/tae/tables/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ import (
"sync/atomic"
"time"

"github.com/matrixorigin/matrixone/pkg/fileservice"
"github.com/matrixorigin/matrixone/pkg/logutil"

"github.com/RoaringBitmap/roaring"
"github.com/matrixorigin/matrixone/pkg/common/bitmap"
"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/mpool"
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/fileservice"
"github.com/matrixorigin/matrixone/pkg/logutil"
"github.com/matrixorigin/matrixone/pkg/objectio"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/blockio"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/catalog"
Expand All @@ -50,7 +49,7 @@ type BlockT[T common.IRef] interface {
GetID() *common.ID
}

func DefaultTOmbstoneFactory(meta *catalog.ObjectEntry) data.Tombstone {
func DefaultTombstoneFactory(meta *catalog.ObjectEntry) data.Tombstone {
return updates.NewObjectMVCCHandle(meta)
}

Expand Down Expand Up @@ -111,10 +110,10 @@ func (blk *baseObject) tryGetMVCC() *updates.ObjectMVCCHandle {
return tombstone.(*updates.ObjectMVCCHandle)
}
func (blk *baseObject) getOrCreateMVCC() *updates.ObjectMVCCHandle {
return blk.meta.GetTable().GetOrCreateTombstone(blk.meta, DefaultTOmbstoneFactory).(*updates.ObjectMVCCHandle)
return blk.meta.GetTable().GetOrCreateTombstone(blk.meta, DefaultTombstoneFactory).(*updates.ObjectMVCCHandle)
}

func (blk *baseObject) GCInMemeoryDeletesByTSForTest(ts types.TS) {
func (blk *baseObject) GCInMemoryDeletesByTSForTest(ts types.TS) {
blk.Lock()
defer blk.Unlock()
mvcc := blk.tryGetMVCC()
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/engine/tae/tables/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ func (factory *DataFactory) MakeObjectFactory() catalog.ObjectDataFactory {
}

func (factory *DataFactory) MakeTombstoneFactory() catalog.TombstoneFactory {
return DefaultTOmbstoneFactory
return DefaultTombstoneFactory
}
2 changes: 1 addition & 1 deletion pkg/vm/engine/tae/tables/txnentries/flushTableTail.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (entry *flushTableTailEntry) PrepareRollback() (err error) {
logutil.Warnf("[FlushTabletail] FT task %d rollback", entry.taskID)
// remove transfer page
for _, id := range entry.pageIds {
_ = entry.rt.TransferTable.DeletePage(id)
entry.rt.TransferTable.DeletePage(id)
}

// why not clean TranDel?
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/engine/tae/tables/txnentries/mergeobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (entry *mergeObjectsEntry) prepareTransferPage() {

func (entry *mergeObjectsEntry) PrepareRollback() (err error) {
for _, id := range entry.pageIds {
_ = entry.rt.TransferTable.DeletePage(id)
entry.rt.TransferTable.DeletePage(id)
}
entry.pageIds = nil
return
Expand Down

0 comments on commit 9f1c2df

Please sign in to comment.