Skip to content

Commit

Permalink
[bug] tae: fix hang issue and reserve some table IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
volgariver6 committed Apr 12, 2024
1 parent e4d8e2a commit ca47fea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/catalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ const (
MO_DATABASE_ID = 1
MO_TABLES_ID = 2
MO_COLUMNS_ID = 3

// MO_RESERVED_MAX is the max reserved table ID.
MO_RESERVED_MAX = 100
)

// index use to update constraint
Expand Down
7 changes: 5 additions & 2 deletions pkg/vm/engine/tae/catalog/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,22 +381,25 @@ func (e *DBEntry) DropTableEntryByID(id uint64, txn txnif.AsyncTxn) (newEntry bo

func (e *DBEntry) CreateTableEntry(schema *Schema, txn txnif.AsyncTxn, dataFactory TableDataFactory) (created *TableEntry, err error) {
e.Lock()
defer e.Unlock()
created = NewTableEntry(e, schema, txn, dataFactory)
err = e.AddEntryLocked(created, txn, false)
e.Unlock()

return created, err
}

func (e *DBEntry) CreateTableEntryWithTableId(schema *Schema, txn txnif.AsyncTxn, dataFactory TableDataFactory, tableId uint64) (created *TableEntry, err error) {
e.Lock()
defer e.Unlock()
if tableId < pkgcatalog.MO_RESERVED_MAX {
return nil, moerr.NewInternalErrorNoCtx("reserved table ID %d", tableId)
}
//Deduplicate for tableId
if _, exist := e.entries[tableId]; exist {
return nil, moerr.GetOkExpectedDup()
}
created = NewTableEntryWithTableId(e, schema, txn, dataFactory, tableId)
err = e.AddEntryLocked(created, txn, false)
e.Unlock()

return created, err
}
Expand Down

0 comments on commit ca47fea

Please sign in to comment.