core/rawdb: several fixes

This commit is contained in:
Gary Rong 2025-01-23 11:21:42 +08:00 committed by Felix Lange
parent 3049d138b7
commit a33bba4773
3 changed files with 6 additions and 5 deletions

View file

@ -210,7 +210,7 @@ func (batch *freezerTableBatch) commit() error {
// Periodically sync the table, todo (rjl493456442) make it configurable?
if time.Since(batch.t.lastSync) > 30*time.Second {
batch.t.lastSync = time.Now()
return batch.t.syncWithNoLock()
return batch.t.Sync()
}
return nil
}

View file

@ -25,8 +25,9 @@ import (
)
const (
freezerTableV1 = 1 // Initial version of metadata struct
freezerTableV2 = 2 // Add field: 'flushOffset'
freezerTableV1 = 1 // Initial version of metadata struct
freezerTableV2 = 2 // Add field: 'flushOffset'
freezerVersion = freezerTableV2 // The current used version
)
// freezerTableMeta is a collection of additional properties that describe the
@ -164,7 +165,7 @@ func (m *freezerTableMeta) write(sync bool) error {
Offset uint64
}
var o obj
o.Version = freezerTableV2 // forcibly set it to v2
o.Version = freezerVersion // forcibly use the current version
o.Tail = m.virtualTail
o.Offset = m.flushOffset

View file

@ -320,7 +320,7 @@ func (t *freezerTable) repair() error {
// offset is updated, leaving a dangling reference that points to a position
// outside the file. If so, the offset will be reset to the new end of the
// file during the next run.
if t.metadata.flushOffset < uint64(newOffset) {
if t.metadata.flushOffset > uint64(newOffset) {
if err := t.metadata.setFlushOffset(uint64(newOffset), true); err != nil {
return err
}