Merge branch 'master' into sup-85

This commit is contained in:
reese 2021-10-28 13:48:20 -05:00 committed by GitHub
commit 327b358bd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -206,6 +206,13 @@ func (db *DB) checkpoint() error {
return nil // skip if transactions open
}
// Check if there are any WAL pages, if not do nothing as
// checkpointing and calling fsync can be very expensive even if
// there are no writes.
if db.walPageN == 0 {
return nil
}
for i := 0; i < db.walPageN; i++ {
page, err := db.readWALPageAt(i)
if err != nil {
@ -245,7 +252,7 @@ func (db *DB) checkpoint() error {
db.walPageN = 0
db.pageMap = NewPageMap()
// Notify halted tranactions that the WAL has been checkpointed.
// Notify halted transactions that the WAL has been checkpointed.
db.haltCond.Broadcast()
return nil