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:
@@ -37,6 +37,9 @@ type Replica interface {
|
||||
// Stops all replication processing. Blocks until processing stopped.
|
||||
Stop(hard bool) error
|
||||
|
||||
// Performs a backup of outstanding WAL frames to the replica.
|
||||
Sync(ctx context.Context) error
|
||||
|
||||
// Returns the last replication position.
|
||||
LastPos() Pos
|
||||
|
||||
@@ -1164,7 +1167,7 @@ func ValidateReplica(ctx context.Context, r Replica) error {
|
||||
|
||||
// Compute checksum of primary database under lock. This prevents a
|
||||
// sync from occurring and the database will not be written.
|
||||
chksum0, pos, err := db.CRC64()
|
||||
chksum0, pos, err := db.CRC64(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot compute checksum: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user