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

Commit3013a78

Browse files
authored
Release 2 5 pg stop backup decomposition2 (#387)
* Rename pg_checksum_enable() to pg_is_checksum_enabled* Remove unused instanceState from pg_start_backup()* Refactor wait_wal_lsn(): remove unused pgBackup * parameter and replace InstanceState * with simple directory string* Refactor pg_stop_backup(): remove useless conn variable* Make some functions and variables (from backup.c) accessible from other compilation units* Remove some references to global stream_wal variable* Remove unused variable externaldir* Yet another split of pg_stop_backup(): separate verification of stop_lsn into wait_wal_and_calculate_stop_lsn()* Create pfilearray_clear_locks() helper function
1 parent151d499 commit3013a78

File tree

8 files changed

+257
-250
lines changed

8 files changed

+257
-250
lines changed

‎src/backup.c

Lines changed: 191 additions & 234 deletions
Large diffs are not rendered by default.

‎src/checkdb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,15 @@ get_index_list(const char *dbname, bool first_db_with_amcheck,
455455
ind->heapallindexed_is_supported=heapallindexed_is_supported;
456456
ind->amcheck_nspname=pgut_malloc(strlen(amcheck_nspname)+1);
457457
strcpy(ind->amcheck_nspname,amcheck_nspname);
458-
pg_atomic_clear_flag(&ind->lock);
459458

460459
if (index_list==NULL)
461460
index_list=parray_new();
462461

463462
parray_append(index_list,ind);
464463
}
465464

465+
pfilearray_clear_locks(index_list);
466+
466467
PQclear(res);
467468

468469
returnindex_list;

‎src/dir.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ pgFileInit(const char *rel_path)
222222
/* Number of blocks backed up during backup */
223223
file->n_headers=0;
224224

225+
// May be add?
226+
// pg_atomic_clear_flag(file->lock);
225227
returnfile;
226228
}
227229

@@ -1859,3 +1861,17 @@ cleanup_tablespace(const char *path)
18591861
parray_walk(files,pgFileFree);
18601862
parray_free(files);
18611863
}
1864+
1865+
/*
1866+
* Clear the synchronisation locks in a parray of (pgFile *)'s
1867+
*/
1868+
void
1869+
pfilearray_clear_locks(parray*file_list)
1870+
{
1871+
inti;
1872+
for (i=0;i<parray_num(file_list);i++)
1873+
{
1874+
pgFile*file= (pgFile*)parray_get(file_list,i);
1875+
pg_atomic_clear_flag(&file->lock);
1876+
}
1877+
}

‎src/pg_probackup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ static char *backup_path = NULL;
6868
staticCatalogState*catalogState=NULL;
6969
/* ================ catalogState (END) =========== */
7070

71-
/* colon separated external directories list ("/path1:/path2") */
72-
char*externaldir=NULL;
7371
/* common options */
7472
intnum_threads=1;
7573
boolstream_wal= false;

‎src/pg_probackup.h

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ typedef struct
600600
intret;
601601
}backup_files_arg;
602602

603-
604603
typedefstructtimelineInfotimelineInfo;
605604

606605
/* struct to collect info about timelines in WAL archive */
@@ -679,10 +678,11 @@ typedef struct BackupPageHeader2
679678
uint16checksum;
680679
}BackupPageHeader2;
681680

682-
typedefstructStopBackupCallbackState {
681+
typedefstructStopBackupCallbackParams
682+
{
683683
PGconn*conn;
684684
intserver_version;
685-
}StopBackupCallbackState;
685+
}StopBackupCallbackParams;
686686

687687
/* Special value for compressed_size field */
688688
#definePageIsOk 0
@@ -1061,6 +1061,7 @@ extern int pgFileCompareRelPathWithExternalDesc(const void *f1, const void *f2);
10611061
externintpgFileCompareLinked(constvoid*f1,constvoid*f2);
10621062
externintpgFileCompareSize(constvoid*f1,constvoid*f2);
10631063
externintpgCompareOid(constvoid*f1,constvoid*f2);
1064+
externvoidpfilearray_clear_locks(parray*file_list);
10641065

10651066
/* in data.c */
10661067
externboolcheck_data_file(ConnectionArgs*arguments,pgFile*file,
@@ -1259,4 +1260,42 @@ extern void start_WAL_streaming(PGconn *backup_conn, char *stream_dst_path,
12591260
ConnectionOptions*conn_opt,
12601261
XLogRecPtrstartpos,TimeLineIDstarttli);
12611262
externintwait_WAL_streaming_end(parray*backup_files_list);
1263+
1264+
/* external variables and functions, implemented in backup.c */
1265+
typedefstructPGStopBackupResult
1266+
{
1267+
/*
1268+
* We will use values of snapshot_xid and invocation_time if there are
1269+
* no transactions between start_lsn and stop_lsn.
1270+
*/
1271+
TransactionIdsnapshot_xid;
1272+
time_tinvocation_time;
1273+
/*
1274+
* Fields that store pg_catalog.pg_stop_backup() result
1275+
*/
1276+
XLogRecPtrlsn;
1277+
size_tbackup_label_content_len;
1278+
char*backup_label_content;
1279+
size_ttablespace_map_content_len;
1280+
char*tablespace_map_content;
1281+
}PGStopBackupResult;
1282+
1283+
externboolbackup_in_progress;
1284+
externparray*backup_files_list;
1285+
1286+
externvoidpg_start_backup(constchar*label,boolsmooth,pgBackup*backup,
1287+
PGNodeInfo*nodeInfo,PGconn*conn);
1288+
externvoidpg_silent_client_messages(PGconn*conn);
1289+
externvoidpg_create_restore_point(PGconn*conn,time_tbackup_start_time);
1290+
externvoidpg_stop_backup_send(PGconn*conn,intserver_version,boolis_started_on_replica,boolis_exclusive,char**query_text);
1291+
externvoidpg_stop_backup_consume(PGconn*conn,intserver_version,
1292+
boolis_exclusive,uint32timeout,constchar*query_text,
1293+
PGStopBackupResult*result);
1294+
externvoidpg_stop_backup_write_file_helper(constchar*path,constchar*filename,constchar*error_msg_filename,
1295+
constvoid*data,size_tlen,parray*file_list);
1296+
externXLogRecPtrwait_wal_lsn(constchar*wal_segment_dir,XLogRecPtrlsn,boolis_start_lsn,TimeLineIDtli,
1297+
boolin_prev_segment,boolsegment_only,
1298+
inttimeout_elevel,boolin_stream_dir);
1299+
externvoidwait_wal_and_calculate_stop_lsn(constchar*xlog_path,XLogRecPtrstop_lsn,pgBackup*backup);
1300+
12621301
#endif/* PG_PROBACKUP_H */

‎src/restore.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
824824
}
825825

826826
/*
827-
* Setup directory structure for external directories and file locks
827+
* Setup directory structure for external directories
828828
*/
829829
for (i=0;i<parray_num(dest_files);i++)
830830
{
@@ -848,11 +848,11 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
848848
elog(VERBOSE,"Create external directory \"%s\"",dirpath);
849849
fio_mkdir(dirpath,file->mode,FIO_DB_HOST);
850850
}
851-
852-
/* setup threads */
853-
pg_atomic_clear_flag(&file->lock);
854851
}
855852

853+
/* setup threads */
854+
pfilearray_clear_locks(dest_files);
855+
856856
/* Get list of files in destination directory and remove redundant files */
857857
if (params->incremental_mode!=INCR_NONE||cleanup_pgdata)
858858
{

‎src/utils/parray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ parray_rm(parray *array, const void *key, int(*compare)(const void *, const void
175175
size_t
176176
parray_num(constparray*array)
177177
{
178-
returnarray->used;
178+
returnarray!=NULL ?array->used : (size_t)0;
179179
}
180180

181181
void

‎src/validate.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
130130
//params->partial_restore_type);
131131

132132
/* setup threads */
133-
for (i=0;i<parray_num(files);i++)
134-
{
135-
pgFile*file= (pgFile*)parray_get(files,i);
136-
pg_atomic_clear_flag(&file->lock);
137-
}
133+
pfilearray_clear_locks(files);
138134

139135
/* init thread args with own file lists */
140136
threads= (pthread_t*)palloc(sizeof(pthread_t)*num_threads);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp