File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,11 @@ const (
113113 last_entry_timestamp TIMESTAMP;
114114 record_count INT;
115115 BEGIN
116+ IF pg_is_in_recovery() THEN
117+ RAISE NOTICE 'Skipping pgbackrest_info update: running on a replica.';
118+ RETURN;
119+ END IF;
120+
116121 SELECT COUNT(*) INTO record_count
117122 FROM exporter.pgbackrestbackupinfo;
118123
@@ -122,18 +127,20 @@ const (
122127 ORDER BY data_time DESC
123128 LIMIT 1;
124129
125- IF last_entry_timestamp < NOW() - INTERVAL '5 minutes' THEN
126- DELETE FROM exporter.pgbackrestbackupinfo;
127- ELSE
130+ IF last_entry_timestamp >= NOW() - INTERVAL '5 minutes' THEN
131+ RAISE NOTICE 'Skipping pgbackrest_info update: data does not need an update (last update at %).', last_entry_timestamp;
128132 RETURN;
129133 END IF;
134+
135+ DELETE FROM exporter.pgbackrestbackupinfo;
130136 END IF;
131137
132138 EXECUTE format(
133139 'COPY exporter.pgbackrestbackupinfo (data) FROM program ''pgbackrest info --output=json'' WITH (FORMAT text, DELIMITER ''|'')'
134140 );
135141 END;
136142 $$ LANGUAGE plpgsql;
143+
137144 `
138145)
139146
You can’t perform that action at this time.
0 commit comments