Skip to content

Commit

Permalink
more and less debug
Browse files Browse the repository at this point in the history
ci-os-only: freebsd
  • Loading branch information
anarazel committed Apr 9, 2022
1 parent eee66c7 commit 212268e
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/backend/storage/buffer/bufmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4336,6 +4336,7 @@ LockBufferForCleanup(Buffer buffer)
ResolveRecoveryConflictWithBufferPin();
/* Reset the published bufid */
SetStartupBufferPinWaitBufId(-1);
elog(DEBUG1, "one cycle of LockBufferForCleanup() iterating in HS");
}
else
ProcWaitForSignal(PG_WAIT_BUFFER_PIN);
Expand Down
5 changes: 5 additions & 0 deletions src/backend/storage/ipc/latch.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,11 @@ SetLatch(Latch *latch)
return;
else if (owner_pid == MyProcPid)
{
if (AmStartupProcess())
{
ereport(DEBUG1, errmsg("setting latch()"));
}

#if defined(WAIT_USE_POLL)
if (waiting)
sendSelfPipeByte();
Expand Down
22 changes: 20 additions & 2 deletions src/backend/storage/ipc/procsignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,14 @@ SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId)
/* Atomically set the proper flag */
slot->pss_signalFlags[reason] = true;
/* Send signal */
return kill(pid, SIGUSR1);
if (kill(pid, SIGUSR1) == 0)
return 0;
else
{
elog(DEBUG1, "failed to kill procsignal %d to pid %d backendid %d: %m",
reason, pid, backendId);
return -1;
}
}
}
else
Expand All @@ -311,11 +318,22 @@ SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId)
/* Atomically set the proper flag */
slot->pss_signalFlags[reason] = true;
/* Send signal */
return kill(pid, SIGUSR1);
if (kill(pid, SIGUSR1) == 0)
return 0;
else
{
elog(DEBUG1, "failed to kill procsignal %d to pid %d backendid %d: %m",
reason, pid, backendId);
return -1;
}
}
}
}

if (AmStartupProcess())
elog(DEBUG1, "failed to send procsignal %d to pid %d backendid %d",
reason, pid, backendId);

errno = ESRCH;
return -1;
}
Expand Down
17 changes: 17 additions & 0 deletions src/backend/tcop/postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -3003,6 +3003,15 @@ RecoveryConflictInterrupt(ProcSignalReason reason)
{
int save_errno = errno;

{
char message[1024];
int ret;

ret = snprintf(message, sizeof(message), "%d: received interrupt %u\n",
getpid(), reason);
write(2, message, ret);
}

/*
* Don't joggle the elbow of proc_exit
*/
Expand Down Expand Up @@ -3040,6 +3049,14 @@ RecoveryConflictInterrupt(ProcSignalReason reason)
if (reason == PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK &&
GetStartupBufferPinWaitBufId() < 0)
CheckDeadLockAlert();
{
char message[1024];
int ret;

ret = snprintf(message, sizeof(message), "%d: no conflicting pin\n",
getpid());
write(2, message, ret);
}
return;
}

Expand Down
5 changes: 5 additions & 0 deletions src/backend/utils/misc/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ schedule_alarm(TimestampTz now)
signal_due_at = nearest_timeout;
signal_pending = true;

if (AmStartupProcess())
{
ereport(DEBUG1, errmsg("setting timeout() in %ld %d", secs, usecs));
}

/* Set the alarm timer */
if (setitimer(ITIMER_REAL, &timeval, NULL) != 0)
{
Expand Down
1 change: 1 addition & 0 deletions src/test/recovery/t/000_0recovery_conflict.pl
1 change: 1 addition & 0 deletions src/test/recovery/t/000_1recovery_conflict.pl
1 change: 1 addition & 0 deletions src/test/recovery/t/000_recovery_conflict.pl
7 changes: 6 additions & 1 deletion src/test/recovery/t/031_recovery_conflict.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# nice to get some minimal coverage of that code.
log_recovery_conflict_waits = on
deadlock_timeout = 10ms
log_min_messages=debug5
log_min_messages=debug1
]);
$node_primary->start;

Expand All @@ -47,6 +47,11 @@
$node_standby->init_from_backup($node_primary, $backup_name,
has_streaming => 1);

$node_standby->append_conf(
'postgresql.conf', qq[
log_min_messages=debug1
]);

$node_standby->start;

my $test_db = "test_db";
Expand Down
1 change: 1 addition & 0 deletions src/test/recovery/t/032_recovery_conflict.pl
1 change: 1 addition & 0 deletions src/test/recovery/t/033_recovery_conflict.pl

0 comments on commit 212268e

Please sign in to comment.