Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc16c52

Browse files
committed
PGPRO-2573: minor changes
1 parent66d03cc commitfc16c52

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

‎src/delete.c

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@ int do_retention(void)
117117
parray*to_purge_list=parray_new();
118118

119119
boolretention_is_set= false;/* At least one retention policy is set */
120+
boolbackup_list_is_empty= false;
120121

121122
/* Get a complete list of backups. */
122123
backup_list=catalog_get_backup_list(INVALID_BACKUP_ID);
123124

125+
/* sanity */
126+
if (parray_num(backup_list)==0)
127+
backup_list_is_empty= true;
128+
124129
if (delete_expired||merge_expired)
125130
{
126131
if (instance_config.retention_redundancy>0)
@@ -142,14 +147,17 @@ int do_retention(void)
142147
retention_is_set= true;
143148
}
144149

150+
if (retention_is_set&&backup_list_is_empty)
151+
elog(WARNING,"Backup list is empty, retention purge and merge are problematic");
152+
145153
/* show fancy message */
146-
if (retention_is_set)
154+
if (retention_is_set&& !backup_list_is_empty)
147155
do_retention_internal(backup_list,to_keep_list,to_purge_list);
148156

149157
if (merge_expired&& !dry_run)
150158
do_retention_merge(backup_list,to_keep_list,to_purge_list);
151159

152-
if (delete_expired&& !dry_run)
160+
if (delete_expired&& !dry_run&& !backup_list_is_empty)
153161
do_retention_purge(to_keep_list,to_purge_list);
154162

155163
/* TODO: some sort of dry run for delete_wal */
@@ -203,40 +211,31 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
203211
if (parray_num(backup_list)==0)
204212
backup_list_is_empty= true;
205213

206-
if (backup_list_is_empty)
207-
{
208-
elog(WARNING,"Backup list is empty, purging won't be executed");
209-
return;
210-
}
211-
212214
/* Get current time */
213215
current_time=time(NULL);
214216

215217
/* Calculate n_full_backups and days_threshold */
216-
if (!backup_list_is_empty)
218+
if (instance_config.retention_redundancy>0)
217219
{
218-
if (instance_config.retention_redundancy>0)
220+
for (i=0;i<parray_num(backup_list);i++)
219221
{
220-
for (i=0;i<parray_num(backup_list);i++)
221-
{
222-
pgBackup*backup= (pgBackup*)parray_get(backup_list,i);
222+
pgBackup*backup= (pgBackup*)parray_get(backup_list,i);
223223

224-
/* Consider only valid backups for Redundancy */
225-
if (instance_config.retention_redundancy>0&&
226-
backup->backup_mode==BACKUP_MODE_FULL&&
227-
(backup->status==BACKUP_STATUS_OK||
228-
backup->status==BACKUP_STATUS_DONE))
229-
{
230-
n_full_backups++;
231-
}
224+
/* Consider only valid backups for Redundancy */
225+
if (instance_config.retention_redundancy>0&&
226+
backup->backup_mode==BACKUP_MODE_FULL&&
227+
(backup->status==BACKUP_STATUS_OK||
228+
backup->status==BACKUP_STATUS_DONE))
229+
{
230+
n_full_backups++;
232231
}
233232
}
233+
}
234234

235-
if (instance_config.retention_window>0)
236-
{
237-
days_threshold=current_time-
238-
(instance_config.retention_window*60*60*24);
239-
}
235+
if (instance_config.retention_window>0)
236+
{
237+
days_threshold=current_time-
238+
(instance_config.retention_window*60*60*24);
240239
}
241240

242241
elog(INFO,"Evaluate backups by retention");
@@ -588,7 +587,7 @@ do_retention_wal(void)
588587
TimeLineIDoldest_tli=0;
589588
boolbackup_list_is_empty= false;
590589

591-
/* Getnew backup_list. Should we */
590+
/* Getlist of backups. */
592591
backup_list=catalog_get_backup_list(INVALID_BACKUP_ID);
593592

594593
if (parray_num(backup_list)==0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp