File tree 1 file changed +18
-1
lines changed 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1253,8 +1253,25 @@ Datum cfs_start_gc(PG_FUNCTION_ARGS)
1253
1253
1254
1254
Datum cfs_enable_gc (PG_FUNCTION_ARGS )
1255
1255
{
1256
+ bool enabled = PG_GETARG_BOOL (0 );
1256
1257
bool was_enabled = cfs_state -> background_gc_enabled ;
1257
- cfs_state -> background_gc_enabled = PG_GETARG_BOOL (0 );
1258
+ cfs_state -> background_gc_enabled = enabled ;
1259
+
1260
+ if (was_enabled && !enabled )
1261
+ {
1262
+ /* Wait until there are no active GC workers */
1263
+ while (pg_atomic_read_u32 (& cfs_state -> n_active_gc ) != 0 )
1264
+ {
1265
+ int rc = WaitLatch (MyLatch ,
1266
+ WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
1267
+ CFS_DISABLE_TIMEOUT /* ms */ );
1268
+ if (rc & WL_POSTMASTER_DEATH )
1269
+ exit (1 );
1270
+
1271
+ ResetLatch (MyLatch );
1272
+ CHECK_FOR_INTERRUPTS ();
1273
+ }
1274
+ }
1258
1275
PG_RETURN_BOOL (was_enabled );
1259
1276
}
1260
1277
You can’t perform that action at this time.
0 commit comments