Sync on close

This commit changes the `replicate` command so that it performs a
final DB sync & replica sync before it exits to ensure it has
backed up all WAL frames at the time of exit.
This commit is contained in:
Ben Johnson
2021-03-21 08:42:07 -06:00
parent 421693130c
commit 0529ce74b7
4 changed files with 80 additions and 61 deletions

View File

@@ -15,7 +15,7 @@ func TestFileReplica_Sync(t *testing.T) {
r := NewTestFileReplica(t, db)
// Sync database & then sync replica.
if err := db.Sync(); err != nil {
if err := db.Sync(context.Background()); err != nil {
t.Fatal(err)
} else if err := r.Sync(context.Background()); err != nil {
t.Fatal(err)
@@ -47,7 +47,7 @@ func TestFileReplica_Sync(t *testing.T) {
// Sync periodically.
if i%100 == 0 || i == n-1 {
if err := db.Sync(); err != nil {
if err := db.Sync(context.Background()); err != nil {
t.Fatal(err)
} else if err := r.Sync(context.Background()); err != nil {
t.Fatal(err)