Skip to content
Snippets Groups Projects
Unverified Commit c7d9840c authored by jiangxinmeng1's avatar jiangxinmeng1 Committed by GitHub
Browse files

fix get node to read (#4663)

read when ts is equal

Approved by: @XuPeng-SH, @fengttt
parent 11b321f5
No related branches found
No related tags found
No related merge requests found
......@@ -208,7 +208,7 @@ func (be *BaseEntry) GetNodeToRead(startts types.TS) (node *UpdateNode) {
}
return true
}
if un.End.Less(startts) {
if un.End.LessEq(startts) {
node = un
return false
}
......
......@@ -658,6 +658,12 @@ func (catalog *Catalog) CreateDBEntry(name string, txnCtx txnif.AsyncTxn) (*DBEn
return entry, err
}
func (catalog *Catalog) CreateDBEntryByTS(name string, ts types.TS) (*DBEntry, error) {
entry := NewDBEntryByTS(catalog, name, ts)
err := catalog.AddEntryLocked(entry, nil)
return entry, err
}
func (catalog *Catalog) RecurLoop(processor Processor) (err error) {
dbIt := catalog.MakeDBIt(true)
for dbIt.Valid() {
......
......@@ -94,6 +94,22 @@ func NewDBEntry(catalog *Catalog, name string, txnCtx txnif.AsyncTxn) *DBEntry {
return e
}
func NewDBEntryByTS(catalog *Catalog, name string, ts types.TS) *DBEntry {
id := catalog.NextDB()
e := &DBEntry{
BaseEntry: NewBaseEntry(id),
catalog: catalog,
name: name,
entries: make(map[uint64]*common.DLNode),
nameNodes: make(map[string]*nodeList),
link: new(common.SortedDList),
}
e.CreateWithTS(ts)
e.acInfo.CreateAt = types.CurrentTimestamp()
return e
}
func NewSystemDBEntry(catalog *Catalog) *DBEntry {
id := SystemDBID
entry := &DBEntry{
......
......@@ -2666,6 +2666,20 @@ func TestDropCreated2(t *testing.T) {
tae.restart()
}
// records create at 1 and commit
// read by ts 1, err should be nil
func TestReadEqualTS(t *testing.T) {
opts := config.WithLongScanAndCKPOpts(nil)
tae := newTestEngine(t, opts)
defer tae.Close()
txn, err := tae.StartTxn(nil)
tae.Catalog.CreateDBEntryByTS("db", txn.GetStartTS())
assert.Nil(t, err)
_, err = txn.GetDatabase("db")
assert.Nil(t, err)
}
func TestTruncateZonemap(t *testing.T) {
type Mod struct {
offset int
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment