pg_abort_backup.patch
text/x-patch
Filename: pg_abort_backup.patch
Type: text/x-patch
Part: 0
Message:
Re: pg_stop_backup does not complete
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| doc/src/sgml/func.sgml | 12 | 1 |
| src/backend/access/transam/xlog.c | 30 | 2 |
| src/include/access/xlog_internal.h | 1 | 0 |
| src/include/catalog/pg_proc.h | 3 | 1 |
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.505
diff -c -r1.505 func.sgml
*** doc/src/sgml/func.sgml 19 Feb 2010 00:15:25 -0000 1.505
--- doc/src/sgml/func.sgml 24 Feb 2010 21:45:05 -0000
***************
*** 13035,13040 ****
--- 13035,13043 ----
<primary>pg_stop_backup</primary>
</indexterm>
<indexterm>
+ <primary>pg_abort_backup</primary>
+ </indexterm>
+ <indexterm>
<primary>pg_switch_xlog</primary>
</indexterm>
<indexterm>
***************
*** 13081,13087 ****
<literal><function>pg_stop_backup</function>()</literal>
</entry>
<entry><type>text</type></entry>
! <entry>Finish performing on-line backup</entry>
</row>
<row>
<entry>
--- 13084,13090 ----
<literal><function>pg_stop_backup</function>()</literal>
</entry>
<entry><type>text</type></entry>
! <entry>Wait for successful completion of an on-line backup</entry>
</row>
<row>
<entry>
***************
*** 13155,13160 ****
--- 13158,13171 ----
transaction log insertion
point is automatically advanced to the next transaction log file, so that the
ending transaction log file can be archived immediately to complete the backup.
+ <function>pg_stop_backup</> waits until all WAL files have been successfully
+ archived before completing, ensuring the backup is now fully complete.
+ </para>
+
+ <para>
+ <function>pg_abort_backup</> removes the label file created by
+ <function>pg_start_backup</> and invalidates any backup taken, allowing an
+ operator override in case of problems.
</para>
<para>
Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/access/transam/xlog.c,v
retrieving revision 1.377
diff -c -r1.377 xlog.c
*** src/backend/access/transam/xlog.c 19 Feb 2010 10:51:03 -0000 1.377
--- src/backend/access/transam/xlog.c 24 Feb 2010 21:45:05 -0000
***************
*** 7968,7974 ****
}
/*
! * pg_stop_backup: finish taking an on-line backup dump
*
* We write an end-of-backup WAL record, and remove the backup label file
* created by pg_start_backup, creating a backup history file in pg_xlog
--- 7968,8002 ----
}
/*
! * pg_abort_backup: abort wait for successful completion of on-line backup
! */
! Datum
! pg_abort_backup(PG_FUNCTION_ARGS)
! {
! if (!superuser())
! ereport(ERROR,
! (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
! (errmsg("must be superuser to run a backup"))));
!
! if (RecoveryInProgress())
! ereport(ERROR,
! (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
! errmsg("recovery is in progress"),
! errhint("WAL control functions cannot be executed during recovery.")));
!
! if (!XLogArchivingActive())
! ereport(ERROR,
! (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
! errmsg("WAL archiving is not active"),
! errhint("archive_mode must be enabled at server start.")));
!
! CancelBackup();
!
! PG_RETURN_VOID();
! }
!
! /*
! * pg_stop_backup: wait for successful completion of on-line backup
*
* We write an end-of-backup WAL record, and remove the backup label file
* created by pg_start_backup, creating a backup history file in pg_xlog
***************
*** 7978,7984 ****
* history file at the beginning of archive recovery, but we now use the WAL
* record for that and the file is for informational and debug purposes only.
*
! * Note: different from CancelBackup which just cancels online backup mode.
*/
Datum
pg_stop_backup(PG_FUNCTION_ARGS)
--- 8006,8012 ----
* history file at the beginning of archive recovery, but we now use the WAL
* record for that and the file is for informational and debug purposes only.
*
! * Note: different from pg_abort_backup() which just cancels online backup mode.
*/
Datum
pg_stop_backup(PG_FUNCTION_ARGS)
Index: src/include/access/xlog_internal.h
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/include/access/xlog_internal.h,v
retrieving revision 1.28
diff -c -r1.28 xlog_internal.h
*** src/include/access/xlog_internal.h 15 Jan 2010 09:19:06 -0000 1.28
--- src/include/access/xlog_internal.h 24 Feb 2010 21:45:05 -0000
***************
*** 262,267 ****
--- 262,268 ----
* These aren't in xlog.h because I'd rather not include fmgr.h there.
*/
extern Datum pg_start_backup(PG_FUNCTION_ARGS);
+ extern Datum pg_abort_backup(PG_FUNCTION_ARGS);
extern Datum pg_stop_backup(PG_FUNCTION_ARGS);
extern Datum pg_switch_xlog(PG_FUNCTION_ARGS);
extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.569
diff -c -r1.569 pg_proc.h
*** src/include/catalog/pg_proc.h 16 Feb 2010 22:34:56 -0000 1.569
--- src/include/catalog/pg_proc.h 24 Feb 2010 21:45:05 -0000
***************
*** 3303,3309 ****
DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 1 0 0 f f f t f v 2 0 25 "25 16" _null_ _null_ _null_ _null_ pg_start_backup _null_ _null_ _null_ ));
DESCR("prepare for taking an online backup");
DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_stop_backup _null_ _null_ _null_ ));
! DESCR("finish taking an online backup");
DATA(insert OID = 2848 ( pg_switch_xlog PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_switch_xlog _null_ _null_ _null_ ));
DESCR("switch to new xlog file");
DATA(insert OID = 2849 ( pg_current_xlog_location PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_current_xlog_location _null_ _null_ _null_ ));
--- 3303,3311 ----
DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 1 0 0 f f f t f v 2 0 25 "25 16" _null_ _null_ _null_ _null_ pg_start_backup _null_ _null_ _null_ ));
DESCR("prepare for taking an online backup");
DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_stop_backup _null_ _null_ _null_ ));
! DESCR("wait for successful online backup");
! DATA(insert OID = 2614 ( pg_abort_backup PGNSP PGUID 12 1 0 0 f f f t f v 0 0 2278 "" _null_ _null_ _null_ _null_ pg_abort_backup _null_ _null_ _null_ ));
! DESCR("abort an online backup");
DATA(insert OID = 2848 ( pg_switch_xlog PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_switch_xlog _null_ _null_ _null_ ));
DESCR("switch to new xlog file");
DATA(insert OID = 2849 ( pg_current_xlog_location PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_current_xlog_location _null_ _null_ _null_ ));