mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Simplify some ERROR paths clearing wait events and transient files
Transient files and wait events get normally cleaned up when seeing an exception (be it in the context of a transaction for a backend or another process like the checkpointer), hence there is little point in complicating error code paths to do this work. This shaves a bit of code, and removes some extra handling with errno which needed to be preserved during the cleanup steps done. Reported-by: Masahiko Sawada Author: Michael Paquier Reviewed-by: Tom Lane, Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoDhHYVq5KkXfkaHhmjA-zJYj-e4teiRAJefvXuKJz1tKQ@mail.gmail.com
This commit is contained in:
@@ -579,12 +579,9 @@ CheckPointReplicationOrigin(void)
|
||||
errno = 0;
|
||||
if ((write(tmpfd, &magic, sizeof(magic))) != sizeof(magic))
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
CloseTransientFile(tmpfd);
|
||||
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
errno = save_errno ? save_errno : ENOSPC;
|
||||
if (errno == 0)
|
||||
errno = ENOSPC;
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
@@ -624,12 +621,9 @@ CheckPointReplicationOrigin(void)
|
||||
if ((write(tmpfd, &disk_state, sizeof(disk_state))) !=
|
||||
sizeof(disk_state))
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
CloseTransientFile(tmpfd);
|
||||
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
errno = save_errno ? save_errno : ENOSPC;
|
||||
if (errno == 0)
|
||||
errno = ENOSPC;
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
@@ -646,12 +640,9 @@ CheckPointReplicationOrigin(void)
|
||||
errno = 0;
|
||||
if ((write(tmpfd, &crc, sizeof(crc))) != sizeof(crc))
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
CloseTransientFile(tmpfd);
|
||||
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
errno = save_errno ? save_errno : ENOSPC;
|
||||
if (errno == 0)
|
||||
errno = ENOSPC;
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
|
Reference in New Issue
Block a user