Revert validation mismatch temp file persistence
This commit reverts 4e469f8 which was used for debugging the validation
stall corruption issue. It can cause the disk to fill with temporary
files though so it is being reverted.
This commit is contained in:
13
db.go
13
db.go
@@ -1625,7 +1625,7 @@ func restoreWAL(ctx context.Context, r Replica, generation string, index int, db
|
|||||||
// unable to checkpoint during this time.
|
// unable to checkpoint during this time.
|
||||||
//
|
//
|
||||||
// If dst is set, the database file is copied to that location before checksum.
|
// If dst is set, the database file is copied to that location before checksum.
|
||||||
func (db *DB) CRC64(dst string) (uint64, Pos, error) {
|
func (db *DB) CRC64() (uint64, Pos, error) {
|
||||||
db.mu.Lock()
|
db.mu.Lock()
|
||||||
defer db.mu.Unlock()
|
defer db.mu.Unlock()
|
||||||
|
|
||||||
@@ -1655,16 +1655,7 @@ func (db *DB) CRC64(dst string) (uint64, Pos, error) {
|
|||||||
}
|
}
|
||||||
pos.Offset = 0
|
pos.Offset = 0
|
||||||
|
|
||||||
// Copy file, if dst specified.
|
chksum, err := checksumFile(db.Path())
|
||||||
checksumPath := db.Path()
|
|
||||||
if dst != "" {
|
|
||||||
if err := copyFile(dst, db.Path()); err != nil {
|
|
||||||
return 0, Pos{}, err
|
|
||||||
}
|
|
||||||
checksumPath = dst
|
|
||||||
}
|
|
||||||
|
|
||||||
chksum, err := checksumFile(checksumPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, pos, err
|
return 0, pos, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ func TestDB_CRC64(t *testing.T) {
|
|||||||
t.Run("ErrNotExist", func(t *testing.T) {
|
t.Run("ErrNotExist", func(t *testing.T) {
|
||||||
db := MustOpenDB(t)
|
db := MustOpenDB(t)
|
||||||
defer MustCloseDB(t, db)
|
defer MustCloseDB(t, db)
|
||||||
if _, _, err := db.CRC64(""); !os.IsNotExist(err) {
|
if _, _, err := db.CRC64(); !os.IsNotExist(err) {
|
||||||
t.Fatalf("unexpected error: %#v", err)
|
t.Fatalf("unexpected error: %#v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -131,7 +131,7 @@ func TestDB_CRC64(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
chksum0, _, err := db.CRC64("")
|
chksum0, _, err := db.CRC64()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ func TestDB_CRC64(t *testing.T) {
|
|||||||
// Issue change that is applied to the WAL. Checksum should not change.
|
// Issue change that is applied to the WAL. Checksum should not change.
|
||||||
if _, err := sqldb.Exec(`CREATE TABLE t (id INT);`); err != nil {
|
if _, err := sqldb.Exec(`CREATE TABLE t (id INT);`); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if chksum1, _, err := db.CRC64(""); err != nil {
|
} else if chksum1, _, err := db.CRC64(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if chksum0 == chksum1 {
|
} else if chksum0 == chksum1 {
|
||||||
t.Fatal("expected different checksum event after WAL change")
|
t.Fatal("expected different checksum event after WAL change")
|
||||||
@@ -150,7 +150,7 @@ func TestDB_CRC64(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if chksum2, _, err := db.CRC64(""); err != nil {
|
if chksum2, _, err := db.CRC64(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if chksum0 == chksum2 {
|
} else if chksum0 == chksum2 {
|
||||||
t.Fatal("expected different checksums after checkpoint")
|
t.Fatal("expected different checksums after checkpoint")
|
||||||
|
|||||||
@@ -1049,11 +1049,12 @@ func ValidateReplica(ctx context.Context, r Replica) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
// Compute checksum of primary database under lock. This prevents a
|
// Compute checksum of primary database under lock. This prevents a
|
||||||
// sync from occurring and the database will not be written.
|
// sync from occurring and the database will not be written.
|
||||||
primaryPath := filepath.Join(tmpdir, "primary")
|
primaryPath := filepath.Join(tmpdir, "primary")
|
||||||
chksum0, pos, err := db.CRC64(primaryPath)
|
chksum0, pos, err := db.CRC64()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot compute checksum: %w", err)
|
return fmt.Errorf("cannot compute checksum: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user