0001-Initial-POC-on-parallel-backup_fix_errors_warnings_delta.patch
text/x-patch
Filename: 0001-Initial-POC-on-parallel-backup_fix_errors_warnings_delta.patch
Type: text/x-patch
Part: 0
Message:
Re: WIP/PoC for parallel backup
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch 0001
| File | + | − |
|---|---|---|
| src/backend/replication/basebackup.c | 8 | 7 |
| src/bin/pg_basebackup/pg_basebackup.c | 7 | 4 |
commit 0d7433e44123b486b48f2071b24f1eaef46f4849
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Date: Thu Oct 3 12:58:55 2019 +0530
Fix errors and warnings.
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index ef55bd0..32ed160 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -346,6 +346,7 @@ perform_base_backup(basebackup_options *opt)
{
/* save backup label into temp file for now. So stop backup can send it to pg_basebackup later on. */
FILE *fp = AllocateFile(TMP_BACKUP_LABEL_FILE, "w");
+
if (!fp)
ereport(ERROR,
(errcode_for_file_access(),
@@ -1627,8 +1628,8 @@ StopBackup(basebackup_options *opt)
XLogRecPtr endptr;
char *labelfile;
struct stat statbuf;
- int r;
StringInfoData buf;
+ FILE *lfp;
/* Disable throttling. */
throttling_counter = -1;
@@ -1648,7 +1649,7 @@ StopBackup(basebackup_options *opt)
sendFile(TMP_BACKUP_LABEL_FILE, BACKUP_LABEL_FILE, &statbuf, false, InvalidOid);
/* read backup_label file into buffer, we need it for do_pg_stop_backup */
- FILE *lfp = AllocateFile(TMP_BACKUP_LABEL_FILE, "r");
+ lfp = AllocateFile(TMP_BACKUP_LABEL_FILE, "r");
if (!lfp)
{
ereport(ERROR,
@@ -1658,7 +1659,7 @@ StopBackup(basebackup_options *opt)
}
labelfile = palloc(statbuf.st_size + 1);
- r = fread(labelfile, statbuf.st_size, 1, lfp);
+ fread(labelfile, statbuf.st_size, 1, lfp);
labelfile[statbuf.st_size] = '\0';
@@ -1692,6 +1693,7 @@ SendBackupFileList(List *tablespaces)
{
StringInfoData buf;
ListCell *lc;
+ pathinfo *pi;
List *files = NIL;
foreach(lc, tablespaces)
@@ -1704,7 +1706,6 @@ SendBackupFileList(List *tablespaces)
}
// add backup label file
- pathinfo *pi;
MAKE_PATHINFO(false, TMP_BACKUP_LABEL_FILE);
files = lcons(pi, files);
@@ -1736,15 +1737,15 @@ SendBackupFileList(List *tablespaces)
{
pathinfo *pi = (pathinfo *) lfirst(lc);
char *path = pi->path;
+ Size len;
/* Send one datarow message */
pq_beginmessage(&buf, 'D');
pq_sendint16(&buf, 2); /* number of columns */
- int32 isdir = pi->isdir ? 1 : 0;
- send_int8_string(&buf, isdir);
+ send_int8_string(&buf, (pi->isdir ? 1 : 0));
- Size len = strlen(path);
+ len = strlen(path);
pq_sendint32(&buf, len);
pq_sendbytes(&buf, path, len);
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 1637735..a316cc6 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -1864,6 +1864,7 @@ BaseBackup(void)
{
SimpleStringList files = {NULL, NULL};
SimpleStringList **worker_files;
+ int num_files;
/*
* Get the header
@@ -1881,7 +1882,7 @@ BaseBackup(void)
exit(1);
}
- int num_files = 0;
+ num_files = 0;
for (i = 0; i < PQntuples(res); i++)
{
bool isdir = atoi(PQgetvalue(res, i, 0));
@@ -2537,6 +2538,7 @@ getFiles(SimpleStringList *files)
SimpleStringListCell *cell;
PGresult *res = NULL;
int i = 0;
+ PGconn *worker_conn;
PQExpBuffer buf;
buf = createPQExpBuffer();
@@ -2561,7 +2563,7 @@ getFiles(SimpleStringList *files)
}
appendPQExpBufferStr(buf, " )");
- PGconn *worker_conn = GetConnection();
+ worker_conn = GetConnection();
if (!worker_conn)
return 1;
@@ -2623,9 +2625,10 @@ divideFilesList(SimpleStringList *files, int numFiles)
static void
create_workers_and_fetch(SimpleStringList **worker_files)
{
+ int i;
+
worker_process = (int*) palloc(sizeof(int) * numWorkers);
- int status;
- int pid, i;
+
for (i = 0; i < numWorkers; i++)
{
worker_process[i] = fork();