PostgreSQL Source Code git master
Loading...
Searching...
No Matches
datachecksum_state.h File Reference
Include dependency graph for datachecksum_state.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum DataChecksumsWorkerOperation DataChecksumsWorkerOperation
 

Enumerations

enum  DataChecksumsWorkerOperation { ENABLE_DATACHECKSUMS , DISABLE_DATACHECKSUMS }
 
enum  DataChecksumsWorkerResult { DATACHECKSUMSWORKER_SUCCESSFUL = 0 , DATACHECKSUMSWORKER_ABORTED , DATACHECKSUMSWORKER_FAILED , DATACHECKSUMSWORKER_DROPDB }
 

Functions

bool AbsorbDataChecksumsBarrier (ProcSignalBarrierType barrier)
 
void EmitAndWaitDataChecksumsBarrier (uint32 state)
 
void StartDataChecksumsWorkerLauncher (DataChecksumsWorkerOperation op, int cost_delay, int cost_limit)
 
void DataChecksumsWorkerLauncherMain (Datum arg)
 
void DataChecksumsWorkerMain (Datum arg)
 

Typedef Documentation

◆ DataChecksumsWorkerOperation

Enumeration Type Documentation

◆ DataChecksumsWorkerOperation

Enumerator
ENABLE_DATACHECKSUMS 
DISABLE_DATACHECKSUMS 

Definition at line 21 of file datachecksum_state.h.

◆ DataChecksumsWorkerResult

Enumerator
DATACHECKSUMSWORKER_SUCCESSFUL 
DATACHECKSUMSWORKER_ABORTED 
DATACHECKSUMSWORKER_FAILED 
DATACHECKSUMSWORKER_DROPDB 

Definition at line 31 of file datachecksum_state.h.

Function Documentation

◆ AbsorbDataChecksumsBarrier()

bool AbsorbDataChecksumsBarrier ( ProcSignalBarrierType  barrier)

Definition at line 430 of file datachecksum_state.c.

431{
433 int current = data_checksums;
434 bool found = false;
435
436 /*
437 * Translate the barrier condition to the target state, doing it here
438 * instead of in the procsignal code saves the latter from knowing about
439 * checksum states.
440 */
441 switch (barrier)
442 {
445 break;
448 break;
451 break;
454 break;
455 default:
456 elog(ERROR, "incorrect barrier \"%i\" received", barrier);
457 }
458
459 /*
460 * If the target state matches the current state then the barrier has been
461 * repeated.
462 */
463 if (current == target_state)
464 return true;
465
466 /*
467 * If the cluster is in recovery we skip the validation of current state
468 * since the replay is trusted.
469 */
470 if (RecoveryInProgress())
471 {
473 return true;
474 }
475
476 /*
477 * Find the barrier condition definition for the target state. Not finding
478 * a condition would be a grave programmer error as the states are a
479 * discrete set.
480 */
481 for (int i = 0; i < lengthof(checksum_barriers) && !found; i++)
482 {
483 if (checksum_barriers[i].from == current && checksum_barriers[i].to == target_state)
484 found = true;
485 }
486
487 /*
488 * If the relevant state criteria aren't satisfied, throw an error which
489 * will be caught by the procsignal machinery for a later retry.
490 */
491 if (!found)
494 errmsg("incorrect data checksum state %i for target state %i",
495 current, target_state));
496
498 return true;
499}
uint32_t uint32
Definition c.h:624
#define lengthof(array)
Definition c.h:873
@ PG_DATA_CHECKSUM_VERSION
Definition checksum.h:29
@ PG_DATA_CHECKSUM_INPROGRESS_OFF
Definition checksum.h:30
@ PG_DATA_CHECKSUM_INPROGRESS_ON
Definition checksum.h:31
@ PG_DATA_CHECKSUM_OFF
Definition checksum.h:28
static const ChecksumBarrierCondition checksum_barriers[9]
int errcode(int sqlerrcode)
Definition elog.c:875
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define ereport(elevel,...)
Definition elog.h:152
int i
Definition isn.c:77
static char * errmsg
static THREAD_BARRIER_T barrier
Definition pgbench.c:488
static int fb(int x)
@ PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_OFF
Definition procsignal.h:55
@ PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_ON
Definition procsignal.h:54
@ PROCSIGNAL_BARRIER_CHECKSUM_ON
Definition procsignal.h:56
@ PROCSIGNAL_BARRIER_CHECKSUM_OFF
Definition procsignal.h:53
bool RecoveryInProgress(void)
Definition xlog.c:6834
void SetLocalDataChecksumState(uint32 data_checksum_version)
Definition xlog.c:4970
int data_checksums
Definition xlog.c:683

References barrier, checksum_barriers, data_checksums, elog, ereport, errcode(), errmsg, ERROR, fb(), i, lengthof, PG_DATA_CHECKSUM_INPROGRESS_OFF, PG_DATA_CHECKSUM_INPROGRESS_ON, PG_DATA_CHECKSUM_OFF, PG_DATA_CHECKSUM_VERSION, PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_OFF, PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_ON, PROCSIGNAL_BARRIER_CHECKSUM_OFF, PROCSIGNAL_BARRIER_CHECKSUM_ON, RecoveryInProgress(), and SetLocalDataChecksumState().

Referenced by ProcessProcSignalBarrier().

◆ DataChecksumsWorkerLauncherMain()

void DataChecksumsWorkerLauncherMain ( Datum  arg)

Definition at line 1049 of file datachecksum_state.c.

1050{
1051
1053 errmsg("background worker \"datachecksums launcher\" started"));
1054
1059
1061
1064
1065 INJECTION_POINT("datachecksumsworker-launcher-delay", NULL);
1066
1068
1070 {
1071 ereport(LOG,
1072 errmsg("background worker \"datachecksums launcher\" already running, exiting"));
1073 /* Launcher was already running, let it finish */
1075 return;
1076 }
1077
1079 launcher_running = true;
1080
1081 /* Initialize a connection to shared catalogs only */
1083
1090
1091 /*
1092 * The target state can change while we are busy enabling/disabling
1093 * checksums, if the user calls pg_disable/enable_data_checksums() before
1094 * we are finished with the previous request. In that case, we will loop
1095 * back here, to process the new request.
1096 */
1097again:
1098
1100 InvalidOid);
1101
1103 {
1104 /*
1105 * If we are asked to enable checksums in a cluster which already has
1106 * checksums enabled, exit immediately as there is nothing more to do.
1107 */
1109 goto done;
1110
1111 ereport(LOG,
1112 errmsg("enabling data checksums requested, starting data checksum calculation"));
1113
1114 /*
1115 * Set the state to inprogress-on and wait on the procsignal barrier.
1116 */
1120
1121 /*
1122 * All backends are now in inprogress-on state and are writing data
1123 * checksums. Start processing all data at rest.
1124 */
1125 if (!ProcessAllDatabases())
1126 {
1127 /*
1128 * If the target state changed during processing then it's not a
1129 * failure, so restart processing instead.
1130 */
1133 {
1135 goto done;
1136 }
1138 ereport(ERROR,
1140 errmsg("unable to enable data checksums in cluster"));
1141 }
1142
1143 /*
1144 * Data checksums have been set on all pages, set the state to on in
1145 * order to instruct backends to validate checksums on reading.
1146 */
1148
1149 ereport(LOG,
1150 errmsg("data checksums are now enabled"));
1151 }
1152 else if (operation == DISABLE_DATACHECKSUMS)
1153 {
1154 ereport(LOG,
1155 errmsg("disabling data checksums requested"));
1156
1160 ereport(LOG,
1161 errmsg("data checksums are now disabled"));
1162 }
1163 else
1164 Assert(false);
1165
1166done:
1167
1168 /*
1169 * This state will only be displayed for a fleeting moment, but for the
1170 * sake of correctness it is still added before ending the command.
1171 */
1174
1175 /*
1176 * All done. But before we exit, check if the target state was changed
1177 * while we were running. In that case we will have to start all over
1178 * again.
1179 */
1182 {
1188 goto again;
1189 }
1190
1191 /* Shut down progress reporting as we are done */
1193
1194 launcher_running = false;
1197}
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_end_command(void)
@ PROGRESS_COMMAND_DATACHECKSUMS
void BackgroundWorkerUnblockSignals(void)
Definition bgworker.c:949
void BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
Definition bgworker.c:909
#define Assert(condition)
Definition c.h:943
static DataChecksumsStateStruct * DataChecksumState
static volatile sig_atomic_t launcher_running
static DataChecksumsWorkerOperation operation
static void launcher_cancel_handler(SIGNAL_ARGS)
static bool ProcessAllDatabases(void)
static void launcher_exit(int code, Datum arg)
#define LOG
Definition elog.h:32
#define DEBUG1
Definition elog.h:31
#define INJECTION_POINT(name, arg)
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition ipc.c:372
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition lwlock.c:1150
void LWLockRelease(LWLock *lock)
Definition lwlock.c:1767
@ LW_EXCLUSIVE
Definition lwlock.h:104
@ B_DATACHECKSUMSWORKER_LAUNCHER
Definition miscadmin.h:373
BackendType MyBackendType
Definition miscinit.c:65
#define die(msg)
#define pqsignal
Definition port.h:548
#define PG_SIG_IGN
Definition port.h:552
#define InvalidOid
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:696
#define PROGRESS_DATACHECKSUMS_PHASE_DONE
Definition progress.h:205
#define PROGRESS_DATACHECKSUMS_PHASE
Definition progress.h:192
#define PROGRESS_DATACHECKSUMS_PHASE_ENABLING
Definition progress.h:201
#define PROGRESS_DATACHECKSUMS_PHASE_DISABLING
Definition progress.h:202
void init_ps_display(const char *fixed_part)
Definition ps_status.c:286
DataChecksumsWorkerOperation launch_operation
DataChecksumsWorkerOperation operation
#define SIGUSR1
Definition win32_port.h:170
#define SIGUSR2
Definition win32_port.h:171
void SetDataChecksumsOff(void)
Definition xlog.c:4866
bool DataChecksumsNeedVerify(void)
Definition xlog.c:4733
void SetDataChecksumsOn(void)
Definition xlog.c:4802
void SetDataChecksumsOnInProgress(void)
Definition xlog.c:4749

References Assert, B_DATACHECKSUMSWORKER_LAUNCHER, BackgroundWorkerInitializeConnectionByOid(), BackgroundWorkerUnblockSignals(), DataChecksumsStateStruct::cost_delay, DataChecksumsStateStruct::cost_limit, DataChecksumsNeedVerify(), DataChecksumState, DEBUG1, die, DISABLE_DATACHECKSUMS, ENABLE_DATACHECKSUMS, ereport, errcode(), errmsg, ERROR, fb(), init_ps_display(), INJECTION_POINT, InvalidOid, DataChecksumsStateStruct::launch_cost_delay, DataChecksumsStateStruct::launch_cost_limit, DataChecksumsStateStruct::launch_operation, launcher_cancel_handler(), launcher_exit(), DataChecksumsStateStruct::launcher_running, launcher_running, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyBackendType, on_shmem_exit(), DataChecksumsStateStruct::operation, operation, PG_SIG_IGN, pgstat_progress_end_command(), pgstat_progress_start_command(), pgstat_progress_update_param(), pqsignal, ProcessAllDatabases(), procsignal_sigusr1_handler(), PROGRESS_COMMAND_DATACHECKSUMS, PROGRESS_DATACHECKSUMS_PHASE, PROGRESS_DATACHECKSUMS_PHASE_DISABLING, PROGRESS_DATACHECKSUMS_PHASE_DONE, PROGRESS_DATACHECKSUMS_PHASE_ENABLING, SetDataChecksumsOff(), SetDataChecksumsOn(), SetDataChecksumsOnInProgress(), SIGUSR1, and SIGUSR2.

◆ DataChecksumsWorkerMain()

void DataChecksumsWorkerMain ( Datum  arg)

Definition at line 1504 of file datachecksum_state.c.

1505{
1506 Oid dboid = DatumGetObjectId(arg);
1509 BufferAccessStrategy strategy;
1510 bool aborted = false;
1512#ifdef USE_INJECTION_POINTS
1513 bool retried = false;
1514#endif
1515
1517
1520
1522
1525
1528
1529 /* worker will have a separate entry in pg_stat_progress_data_checksums */
1531 InvalidOid);
1532
1533 /*
1534 * Get a list of all temp tables present as we start in this database. We
1535 * need to wait until they are all gone until we are done, since we cannot
1536 * access these relations and modify them.
1537 */
1539
1540 /*
1541 * Enable vacuum cost delay, if any. While this process isn't doing any
1542 * vacuuming, we are re-using the infrastructure that vacuum cost delay
1543 * provides rather than inventing something bespoke. This is an internal
1544 * implementation detail and care should be taken to avoid it bleeding
1545 * through to the user to avoid confusion.
1546 *
1547 * VacuumUpdateCosts() propagates the values to the variables actually
1548 * read by vacuum_delay_point().
1549 */
1554
1555 /*
1556 * Create and set the vacuum strategy as our buffer strategy.
1557 */
1558 strategy = GetAccessStrategy(BAS_VACUUM);
1559
1562
1563 /* Update the total number of relations to be processed in this DB. */
1564 {
1565 const int index[] = {
1568 };
1569
1570 int64 vals[2];
1571
1572 vals[0] = list_length(RelationList);
1573 vals[1] = 0;
1574
1576 }
1577
1578 /* Process the relations */
1579 rels_done = 0;
1580 foreach_oid(reloid, RelationList)
1581 {
1582 bool costs_updated = false;
1583
1584 if (!ProcessSingleRelationByOid(reloid, strategy))
1585 {
1586 aborted = true;
1587 break;
1588 }
1589
1591 ++rels_done);
1594
1595 if (abort_requested)
1596 break;
1597
1598 /*
1599 * Check if the cost settings changed during runtime and if so, update
1600 * to reflect the new values and signal that the access strategy needs
1601 * to be refreshed.
1602 */
1606 {
1607 costs_updated = true;
1611
1614 }
1615 else
1616 costs_updated = false;
1618
1619 if (costs_updated)
1620 {
1621 FreeAccessStrategy(strategy);
1622 strategy = GetAccessStrategy(BAS_VACUUM);
1623 }
1624 }
1625
1627 FreeAccessStrategy(strategy);
1628
1629 if (aborted || abort_requested)
1630 {
1635 errmsg("data checksum processing aborted in database OID %u",
1636 dboid));
1637 return;
1638 }
1639
1640 /* The worker is about to wait for temporary tables to go away. */
1643
1644 /*
1645 * Wait for all temp tables that existed when we started to go away. This
1646 * is necessary since we cannot "reach" them to enable checksums. Any temp
1647 * tables created after we started will already have checksums in them
1648 * (due to the "inprogress-on" state), so no need to wait for those.
1649 */
1650 for (;;)
1651 {
1653 int numleft;
1654 char activity[64];
1655
1656 CurrentTempTables = BuildRelationList(true, false);
1657 numleft = 0;
1659 {
1661 numleft++;
1662 }
1664
1665#ifdef USE_INJECTION_POINTS
1666 if (IS_INJECTION_POINT_ATTACHED("datachecksumsworker-fake-temptable-wait"))
1667 {
1668 /* Make sure to just cause one retry */
1669 if (!retried && numleft == 0)
1670 {
1671 numleft = 1;
1672 retried = true;
1673
1674 INJECTION_POINT_CACHED("datachecksumsworker-fake-temptable-wait", NULL);
1675 }
1676 }
1677#endif
1678
1679 if (numleft == 0)
1680 break;
1681
1682 /*
1683 * At least one temp table is left to wait for, indicate in pgstat
1684 * activity and progress reporting.
1685 */
1687 sizeof(activity),
1688 "Waiting for %d temp tables to be removed", numleft);
1690
1691 /* Retry every 3 seconds */
1695 3000,
1697
1700
1701 if (aborted || abort_requested)
1702 {
1706 ereport(LOG,
1707 errmsg("data checksum processing aborted in database OID %u",
1708 dboid));
1709 return;
1710 }
1711 }
1712
1714
1715 /* worker done */
1717
1721}
void VacuumUpdateCosts(void)
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
void pgstat_report_activity(BackendState state, const char *cmd_str)
@ STATE_RUNNING
#define BGWORKER_BYPASS_ALLOWCONN
Definition bgworker.h:166
@ BAS_VACUUM
Definition bufmgr.h:40
int64_t int64
Definition c.h:621
static volatile sig_atomic_t abort_requested
static bool ProcessSingleRelationByOid(Oid relationId, BufferAccessStrategy strategy)
#define CHECK_FOR_ABORT_REQUEST()
static List * BuildRelationList(bool temp_relations, bool include_shared)
Datum arg
Definition elog.c:1323
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
Definition freelist.c:426
void FreeAccessStrategy(BufferAccessStrategy strategy)
Definition freelist.c:608
int VacuumCostLimit
Definition globals.c:157
int VacuumCostBalance
Definition globals.c:160
struct Latch * MyLatch
Definition globals.c:65
double VacuumCostDelay
Definition globals.c:158
#define IS_INJECTION_POINT_ATTACHED(name)
#define INJECTION_POINT_CACHED(name, arg)
void ResetLatch(Latch *latch)
Definition latch.c:374
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition latch.c:172
void list_free(List *list)
Definition list.c:1546
bool list_member_oid(const List *list, Oid datum)
Definition list.c:722
#define CHECK_FOR_INTERRUPTS()
Definition miscadmin.h:125
@ B_DATACHECKSUMSWORKER_WORKER
Definition miscadmin.h:374
static int list_length(const List *l)
Definition pg_list.h:152
#define NIL
Definition pg_list.h:68
#define foreach_oid(var, lst)
Definition pg_list.h:503
#define snprintf
Definition port.h:261
static Oid DatumGetObjectId(Datum X)
Definition postgres.h:242
unsigned int Oid
#define PROGRESS_DATACHECKSUMS_RELS_TOTAL
Definition progress.h:195
#define PROGRESS_DATACHECKSUMS_PHASE_WAITING_TEMPREL
Definition progress.h:203
#define PROGRESS_DATACHECKSUMS_RELS_DONE
Definition progress.h:196
DataChecksumsWorkerResult success
Definition pg_list.h:54
Definition type.h:97
#define WL_TIMEOUT
#define WL_EXIT_ON_PM_DEATH
#define WL_LATCH_SET

References abort_requested, arg, B_DATACHECKSUMSWORKER_WORKER, BackgroundWorkerInitializeConnectionByOid(), BackgroundWorkerUnblockSignals(), BAS_VACUUM, BGWORKER_BYPASS_ALLOWCONN, BuildRelationList(), CHECK_FOR_ABORT_REQUEST, CHECK_FOR_INTERRUPTS, DataChecksumsStateStruct::cost_delay, DataChecksumsStateStruct::cost_limit, DataChecksumState, DATACHECKSUMSWORKER_ABORTED, DATACHECKSUMSWORKER_SUCCESSFUL, DatumGetObjectId(), DEBUG1, die, ENABLE_DATACHECKSUMS, ereport, errmsg, fb(), foreach_oid, FreeAccessStrategy(), GetAccessStrategy(), init_ps_display(), INJECTION_POINT_CACHED, InvalidOid, IS_INJECTION_POINT_ATTACHED, DataChecksumsStateStruct::launch_cost_delay, DataChecksumsStateStruct::launch_cost_limit, list_free(), list_length(), list_member_oid(), LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyBackendType, MyLatch, NIL, operation, pgstat_progress_end_command(), pgstat_progress_start_command(), pgstat_progress_update_multi_param(), pgstat_progress_update_param(), pgstat_report_activity(), pqsignal, DataChecksumsStateStruct::process_shared_catalogs, ProcessSingleRelationByOid(), procsignal_sigusr1_handler(), PROGRESS_COMMAND_DATACHECKSUMS, PROGRESS_DATACHECKSUMS_PHASE, PROGRESS_DATACHECKSUMS_PHASE_WAITING_TEMPREL, PROGRESS_DATACHECKSUMS_RELS_DONE, PROGRESS_DATACHECKSUMS_RELS_TOTAL, ResetLatch(), SIGUSR1, snprintf, STATE_RUNNING, DataChecksumsStateStruct::success, VacuumCostBalance, VacuumCostDelay, VacuumCostLimit, VacuumUpdateCosts(), WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_TIMEOUT.

◆ EmitAndWaitDataChecksumsBarrier()

void EmitAndWaitDataChecksumsBarrier ( uint32  state)

Definition at line 389 of file datachecksum_state.c.

390{
392
393 switch (state)
394 {
398 break;
399
403 break;
404
408 break;
409
413 break;
414
415 default:
416 Assert(false);
417 }
418}
uint64_t uint64
Definition c.h:625
void WaitForProcSignalBarrier(uint64 generation)
Definition procsignal.c:436
uint64 EmitProcSignalBarrier(ProcSignalBarrierType type)
Definition procsignal.c:368

References Assert, barrier, EmitProcSignalBarrier(), PG_DATA_CHECKSUM_INPROGRESS_OFF, PG_DATA_CHECKSUM_INPROGRESS_ON, PG_DATA_CHECKSUM_OFF, PG_DATA_CHECKSUM_VERSION, PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_OFF, PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_ON, PROCSIGNAL_BARRIER_CHECKSUM_OFF, PROCSIGNAL_BARRIER_CHECKSUM_ON, and WaitForProcSignalBarrier().

Referenced by StartupXLOG(), xlog2_redo(), and xlog_redo().

◆ StartDataChecksumsWorkerLauncher()

void StartDataChecksumsWorkerLauncher ( DataChecksumsWorkerOperation  op,
int  cost_delay,
int  cost_limit 
)

Definition at line 566 of file datachecksum_state.c.

569{
572 bool running;
573
574#ifdef USE_ASSERT_CHECKING
575 /* The cost delay settings have no effect when disabling */
576 if (op == DISABLE_DATACHECKSUMS)
577 Assert(cost_delay == 0 && cost_limit == 0);
578#endif
579
580 INJECTION_POINT("datachecksumsworker-startup-delay", NULL);
581
582 /* Store the desired state in shared memory */
584
588
589 /* Is the launcher already running? If so, what is it doing? */
591
593
594 /*
595 * Launch a new launcher process, if it's not running already.
596 *
597 * If the launcher is currently busy enabling the checksums, and we want
598 * them disabled (or vice versa), the launcher will notice that at latest
599 * when it's about to exit, and will loop back to process the new request.
600 * So if the launcher is already running, we don't need to do anything
601 * more here to abort it.
602 *
603 * If you call pg_enable/disable_data_checksums() twice in a row, before
604 * the launcher has had a chance to start up, we still end up launching it
605 * twice. That's OK, the second invocation will see that a launcher is
606 * already running and exit quickly.
607 */
608 if (!running)
609 {
610 if ((op == ENABLE_DATACHECKSUMS && DataChecksumsOn()) ||
612 {
613 ereport(LOG,
614 errmsg("data checksums already in desired state, exiting"));
615 return;
616 }
617
618 /*
619 * Prepare the BackgroundWorker and launch it.
620 */
621 memset(&bgw, 0, sizeof(bgw));
623 bgw.bgw_start_time = BgWorkerStart_RecoveryFinished;
624 snprintf(bgw.bgw_library_name, BGW_MAXLEN, "postgres");
625 snprintf(bgw.bgw_function_name, BGW_MAXLEN, "DataChecksumsWorkerLauncherMain");
626 snprintf(bgw.bgw_name, BGW_MAXLEN, "datachecksums launcher");
627 snprintf(bgw.bgw_type, BGW_MAXLEN, "datachecksums launcher");
628 bgw.bgw_restart_time = BGW_NEVER_RESTART;
629 bgw.bgw_notify_pid = MyProcPid;
630 bgw.bgw_main_arg = (Datum) 0;
631
635 errmsg("failed to start background worker to process data checksums"));
636 }
637 else
638 {
639 ereport(LOG,
640 errmsg("data checksum processing already running"));
641 }
642}
bool RegisterDynamicBackgroundWorker(BackgroundWorker *worker, BackgroundWorkerHandle **handle)
Definition bgworker.c:1068
#define BGW_NEVER_RESTART
Definition bgworker.h:92
@ BgWorkerStart_RecoveryFinished
Definition bgworker.h:88
#define BGWORKER_BACKEND_DATABASE_CONNECTION
Definition bgworker.h:60
#define BGWORKER_SHMEM_ACCESS
Definition bgworker.h:53
#define BGW_MAXLEN
Definition bgworker.h:93
int MyProcPid
Definition globals.c:49
uint64_t Datum
Definition postgres.h:70
bool DataChecksumsOn(void)
Definition xlog.c:4695
bool DataChecksumsOff(void)
Definition xlog.c:4683

References Assert, BGW_MAXLEN, BGW_NEVER_RESTART, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_SHMEM_ACCESS, BgWorkerStart_RecoveryFinished, DataChecksumsOff(), DataChecksumsOn(), DataChecksumState, DISABLE_DATACHECKSUMS, ENABLE_DATACHECKSUMS, ereport, errcode(), errmsg, ERROR, fb(), INJECTION_POINT, DataChecksumsStateStruct::launch_cost_delay, DataChecksumsStateStruct::launch_cost_limit, DataChecksumsStateStruct::launch_operation, DataChecksumsStateStruct::launcher_running, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProcPid, RegisterDynamicBackgroundWorker(), and snprintf.

Referenced by disable_data_checksums(), and enable_data_checksums().