|
57 | 57 | #include"storage/ipc.h"
|
58 | 58 | #include"storage/pg_shmem.h"
|
59 | 59 | #include"storage/pmsignal.h"
|
| 60 | +#include"storage/procsignal.h" |
60 | 61 | #include"utils/guc.h"
|
61 | 62 | #include"utils/memutils.h"
|
62 | 63 | #include"utils/ps_status.h"
|
@@ -278,6 +279,7 @@ static void pgstat_recv_analyze(PgStat_MsgAnalyze *msg, int len);
|
278 | 279 | staticvoidpgstat_recv_bgwriter(PgStat_MsgBgWriter*msg,intlen);
|
279 | 280 | staticvoidpgstat_recv_funcstat(PgStat_MsgFuncstat*msg,intlen);
|
280 | 281 | staticvoidpgstat_recv_funcpurge(PgStat_MsgFuncpurge*msg,intlen);
|
| 282 | +staticvoidpgstat_recv_recoveryconflict(PgStat_MsgRecoveryConflict*msg,intlen); |
281 | 283 |
|
282 | 284 |
|
283 | 285 | /* ------------------------------------------------------------
|
@@ -1314,6 +1316,25 @@ pgstat_report_analyze(Relation rel, bool adopt_counts,
|
1314 | 1316 | pgstat_send(&msg,sizeof(msg));
|
1315 | 1317 | }
|
1316 | 1318 |
|
| 1319 | +/* -------- |
| 1320 | + * pgstat_report_recovery_conflict() - |
| 1321 | + * |
| 1322 | + * Tell the collector about a Hot Standby recovery conflict. |
| 1323 | + * -------- |
| 1324 | + */ |
| 1325 | +void |
| 1326 | +pgstat_report_recovery_conflict(intreason) |
| 1327 | +{ |
| 1328 | +PgStat_MsgRecoveryConflictmsg; |
| 1329 | + |
| 1330 | +if (pgStatSock==PGINVALID_SOCKET|| !pgstat_track_counts) |
| 1331 | +return; |
| 1332 | + |
| 1333 | +pgstat_setheader(&msg.m_hdr,PGSTAT_MTYPE_RECOVERYCONFLICT); |
| 1334 | +msg.m_databaseid=MyDatabaseId; |
| 1335 | +msg.m_reason=reason; |
| 1336 | +pgstat_send(&msg,sizeof(msg)); |
| 1337 | +} |
1317 | 1338 |
|
1318 | 1339 | /* ----------
|
1319 | 1340 | * pgstat_ping() -
|
@@ -3053,6 +3074,10 @@ PgstatCollectorMain(int argc, char *argv[])
|
3053 | 3074 | pgstat_recv_funcpurge((PgStat_MsgFuncpurge*)&msg,len);
|
3054 | 3075 | break;
|
3055 | 3076 |
|
| 3077 | +casePGSTAT_MTYPE_RECOVERYCONFLICT: |
| 3078 | +pgstat_recv_recoveryconflict((PgStat_MsgRecoveryConflict*)&msg,len); |
| 3079 | +break; |
| 3080 | + |
3056 | 3081 | default:
|
3057 | 3082 | break;
|
3058 | 3083 | }
|
@@ -3129,6 +3154,11 @@ pgstat_get_db_entry(Oid databaseid, bool create)
|
3129 | 3154 | result->n_tuples_updated=0;
|
3130 | 3155 | result->n_tuples_deleted=0;
|
3131 | 3156 | result->last_autovac_time=0;
|
| 3157 | +result->n_conflict_tablespace=0; |
| 3158 | +result->n_conflict_lock=0; |
| 3159 | +result->n_conflict_snapshot=0; |
| 3160 | +result->n_conflict_bufferpin=0; |
| 3161 | +result->n_conflict_startup_deadlock=0; |
3132 | 3162 |
|
3133 | 3163 | memset(&hash_ctl,0,sizeof(hash_ctl));
|
3134 | 3164 | hash_ctl.keysize=sizeof(Oid);
|
@@ -4203,6 +4233,45 @@ pgstat_recv_bgwriter(PgStat_MsgBgWriter *msg, int len)
|
4203 | 4233 | globalStats.buf_alloc+=msg->m_buf_alloc;
|
4204 | 4234 | }
|
4205 | 4235 |
|
| 4236 | +/* ---------- |
| 4237 | + * pgstat_recv_recoveryconflict() - |
| 4238 | + * |
| 4239 | + * Process as RECOVERYCONFLICT message. |
| 4240 | + * ---------- |
| 4241 | + */ |
| 4242 | +staticvoid |
| 4243 | +pgstat_recv_recoveryconflict(PgStat_MsgRecoveryConflict*msg,intlen) |
| 4244 | +{ |
| 4245 | +PgStat_StatDBEntry*dbentry; |
| 4246 | +dbentry=pgstat_get_db_entry(msg->m_databaseid, true); |
| 4247 | + |
| 4248 | +switch (msg->m_reason) |
| 4249 | +{ |
| 4250 | +casePROCSIG_RECOVERY_CONFLICT_DATABASE: |
| 4251 | +/* |
| 4252 | + * Since we drop the information about the database as soon |
| 4253 | + * as it replicates, there is no point in counting these |
| 4254 | + * conflicts. |
| 4255 | + */ |
| 4256 | +break; |
| 4257 | +casePROCSIG_RECOVERY_CONFLICT_TABLESPACE: |
| 4258 | +dbentry->n_conflict_tablespace++; |
| 4259 | +break; |
| 4260 | +casePROCSIG_RECOVERY_CONFLICT_LOCK: |
| 4261 | +dbentry->n_conflict_lock++; |
| 4262 | +break; |
| 4263 | +casePROCSIG_RECOVERY_CONFLICT_SNAPSHOT: |
| 4264 | +dbentry->n_conflict_snapshot++; |
| 4265 | +break; |
| 4266 | +casePROCSIG_RECOVERY_CONFLICT_BUFFERPIN: |
| 4267 | +dbentry->n_conflict_bufferpin++; |
| 4268 | +break; |
| 4269 | +casePROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK: |
| 4270 | +dbentry->n_conflict_startup_deadlock++; |
| 4271 | +break; |
| 4272 | +} |
| 4273 | +} |
| 4274 | + |
4206 | 4275 | /* ----------
|
4207 | 4276 | * pgstat_recv_funcstat() -
|
4208 | 4277 | *
|
|