|From:||Michael Paquier <michael(dot)paquier(at)gmail(dot)com>|
|To:||Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>|
|Cc:||Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: [HACKERS] Assertion failure when the non-exclusive pg_stop_backup aborted.|
|Views:||Raw Message | Whole Thread | Download mbox|
On Wed, Nov 15, 2017 at 9:06 AM, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>> On Nov 15, 2017 2:59 AM, "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com> wrote:
>> + /* Quick exit if we have done the backup */
>> + if (XLogCtl->Insert.exclusiveBackupState == EXCLUSIVE_BACKUP_NONE)
>> + return;
>> This quick exit seems to cause another problem. Please imagine the
>> case where there is no exclusive backup running, a backend starts
>> non-exclusive backup and is terminated before calling pg_stop_backup().
>> In this case, do_pg_abort_backup() should decrement
>> XLogCtl->Insert.nonExclusiveBackups, but, with the patch, because of
>> the above quick exit, do_pg_abort_backup() fails to decrement that.
> Hmm, I think that in this case because exclusiveBackupState is not
> EXCLUSIVE_BACKUP_NONE, nonExclusiveBackups is surely decremented. Am I
> missing something?
Nah. Fujii-san is right here as exclusiveBackupState is never updated
for non-exclusive backups. You need an extra check on
sessionBackupState to make sure that even for non-exclusive backups
the counter is correctly decremented if a non-exclusive session lock
is hold. For an exclusive backup, the session lock can be either
SESSION_BACKUP_EXCLUSIVE if an exclusive backup is stopped on the same
session as the start phase, or SESSION_BACKUP_NONE if the exclusive
backup is stopped from a different session. So you'd basically need
+ * Quick exit if we have done the exclusive backup or if session is
+ * not keeping around a started non-exclusive backup.
+ if (XLogCtl->Insert.exclusiveBackupState == EXCLUSIVE_BACKUP_NONE &&
+ sessionBackupState != SESSION_BACKUP_NON_EXCLUSIVE)
At the same time it would be safer at startup phase to update
sessionBackupState when holding the WAL insert lock to prevent other
CHECK_FOR_INTERRUPTS hazards. Suggestion of patch attached.
|Next Message||Nikita Glukhov||2017-11-15 01:17:05||Re: [HACKERS] SQL/JSON in PostgreSQL|
|Previous Message||Amit Langote||2017-11-15 00:59:06||Re: [HACKERS] moving some partitioning code to executor|