Check checkpoint result during restore

This commit is contained in:
Ben Johnson
2021-02-02 15:04:20 -07:00
parent 922fa0798e
commit 6c49fba592

9
db.go
View File

@@ -1591,13 +1591,14 @@ func restoreWAL(ctx context.Context, r Replica, generation string, index int, db
} }
defer d.Close() defer d.Close()
if _, err := d.Exec(`PRAGMA wal_checkpoint(TRUNCATE);`); err != nil { var row [3]int
return err if err := d.QueryRow(`PRAGMA wal_checkpoint(TRUNCATE);`).Scan(&row[0], &row[1], &row[2]); err != nil {
} else if err := d.Close(); err != nil {
return err return err
} else if row[0] != 0 {
return fmt.Errorf("truncation checkpoint failed during restore (%d,%d,%d)", row[0], row[1], row[2])
} }
return nil return d.Close()
} }
// CRC64 returns a CRC-64 ISO checksum of the database and its current position. // CRC64 returns a CRC-64 ISO checksum of the database and its current position.