mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
fix RBF WAL segment reference error
This commit is contained in:
parent
cdd10a26f0
commit
d826cec4b3
2 changed files with 12 additions and 7 deletions
|
|
@ -1660,15 +1660,13 @@ func (tx *Tx) writeBitmapWALPage(pgno uint32, page []byte) (walID int64, err err
|
|||
}
|
||||
|
||||
func (tx *Tx) ensureWritableWALSegment() error {
|
||||
// Ignore if we still have space in the write cache.
|
||||
writeCacheSize := int64(len(tx.wcache))
|
||||
if len(tx.segments) != 0 && activeWALSegment(tx.segments).Size()+writeCacheSize < MaxWALSegmentFileSize {
|
||||
return nil
|
||||
}
|
||||
return tx.addWALSegment()
|
||||
}
|
||||
|
||||
// addWALSegment appends a new, writable segment and closing an existing segments for write.
|
||||
func (tx *Tx) addWALSegment() error {
|
||||
// Flush write cache out to file before adding new segment.
|
||||
if err := tx.flushWALWriter(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
13
rbf/wal.go
13
rbf/wal.go
|
|
@ -122,9 +122,9 @@ func (s *WALSegment) ReadWALPage(walID int64) ([]byte, error) {
|
|||
}
|
||||
|
||||
func walSegmentByPath(segments []WALSegment, path string) *WALSegment {
|
||||
for _, segment := range segments {
|
||||
if segment.Path == path {
|
||||
return &segment
|
||||
for i := range segments {
|
||||
if segments[i].Path == path {
|
||||
return &segments[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -247,6 +247,13 @@ func truncateWALAfter(segments []WALSegment, walID int64) ([]WALSegment, error)
|
|||
return newSegments, nil
|
||||
}
|
||||
|
||||
func DumpWALSegments(segments []WALSegment) {
|
||||
fmt.Printf("WAL (%d segments)\n", len(segments))
|
||||
for i, s := range segments {
|
||||
fmt.Printf("[%d] WALIDs=(%d-%d) PageN=%d\n", i, s.MinWALID, s.MaxWALID(), s.PageN)
|
||||
}
|
||||
}
|
||||
|
||||
// FormatWALSegmentPath returns a path for a WAL segment using a WAL ID.
|
||||
func FormatWALSegmentPath(walID int64) string {
|
||||
return fmt.Sprintf("%016x.wal", walID)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue