|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.63 2010/08/13 20:10:50 rhaas Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.64 2010/09/11 15:48:04 heikki Exp $ |
11 | 11 | *
|
12 | 12 | * NOTES
|
13 | 13 | * Each global transaction is associated with a global transaction
|
|
55 | 55 | #include "miscadmin.h"
|
56 | 56 | #include "pg_trace.h"
|
57 | 57 | #include "pgstat.h"
|
| 58 | +#include "replication/walsender.h" |
58 | 59 | #include "storage/fd.h"
|
59 | 60 | #include "storage/procarray.h"
|
60 | 61 | #include "storage/sinvaladt.h"
|
@@ -1025,6 +1026,13 @@ EndPrepare(GlobalTransaction gxact)
|
1025 | 1026 |
|
1026 | 1027 | /* If we crash now, we have prepared: WAL replay will fix things */
|
1027 | 1028 |
|
| 1029 | + /* |
| 1030 | + * Wake up all walsenders to send WAL up to the PREPARE record |
| 1031 | + * immediately if replication is enabled |
| 1032 | + */ |
| 1033 | + if (max_wal_senders > 0) |
| 1034 | + WalSndWakeup(); |
| 1035 | + |
1028 | 1036 | /* write correct CRC and close file */
|
1029 | 1037 | if ((write(fd, &statefile_crc, sizeof(pg_crc32))) != sizeof(pg_crc32))
|
1030 | 1038 | {
|
@@ -2005,6 +2013,13 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
2005 | 2013 | /* Flush XLOG to disk */
|
2006 | 2014 | XLogFlush(recptr);
|
2007 | 2015 |
|
| 2016 | + /* |
| 2017 | + * Wake up all walsenders to send WAL up to the COMMIT PREPARED record |
| 2018 | + * immediately if replication is enabled |
| 2019 | + */ |
| 2020 | + if (max_wal_senders > 0) |
| 2021 | + WalSndWakeup(); |
| 2022 | + |
2008 | 2023 | /* Mark the transaction committed in pg_clog */
|
2009 | 2024 | TransactionIdCommitTree(xid, nchildren, children);
|
2010 | 2025 |
|
@@ -2077,6 +2092,13 @@ RecordTransactionAbortPrepared(TransactionId xid,
|
2077 | 2092 | /* Always flush, since we're about to remove the 2PC state file */
|
2078 | 2093 | XLogFlush(recptr);
|
2079 | 2094 |
|
| 2095 | + /* |
| 2096 | + * Wake up all walsenders to send WAL up to the ABORT PREPARED record |
| 2097 | + * immediately if replication is enabled |
| 2098 | + */ |
| 2099 | + if (max_wal_senders > 0) |
| 2100 | + WalSndWakeup(); |
| 2101 | + |
2080 | 2102 | /*
|
2081 | 2103 | * Mark the transaction aborted in clog. This is not absolutely necessary
|
2082 | 2104 | * but we may as well do it while we are here.
|
|
0 commit comments