Skip to content

Commit b476ed4

Browse files
committed
Prevent snapshot make/remove/switch/recover at replica
1 parent 6e047e2 commit b476ed4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/backend/storage/file/snapfs.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,23 @@ void
269269
sfs_checkpoint(void)
270270
{
271271
int flags = CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT | CHECKPOINT_FLUSH_ALL;
272-
/*
273-
if (InRecovery)
274-
CreateRestartPoint(flags);
275-
else
276-
*/
277272
RequestCheckpoint(flags);
278273
}
279274

275+
static void
276+
sfs_not_at_replica(void)
277+
{
278+
if (RecoveryInProgress())
279+
elog(ERROR, "Operation is not possible at replica");
280+
}
281+
280282
/*
281283
* SQL interface to snapshots
282284
*/
283285

284286
Datum pg_make_snapshot(PG_FUNCTION_ARGS)
285287
{
288+
sfs_not_at_replica();
286289
PG_RETURN_INT32(sfs_make_snapshot());
287290
}
288291

@@ -296,13 +299,15 @@ Datum pg_remove_snapshot(PG_FUNCTION_ARGS)
296299
Datum pg_recover_to_snapshot(PG_FUNCTION_ARGS)
297300
{
298301
SnapshotId snap_id = PG_GETARG_INT32(0);
302+
sfs_not_at_replica();
299303
sfs_recover_to_snapshot(snap_id);
300304
PG_RETURN_VOID();
301305
}
302306

303307
Datum pg_switch_to_snapshot(PG_FUNCTION_ARGS)
304308
{
305309
SnapshotId snap_id = PG_GETARG_INT32(0);
310+
sfs_not_at_replica();
306311
sfs_switch_to_snapshot(snap_id);
307312
PG_RETURN_VOID();
308313
}

0 commit comments

Comments
 (0)