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

Commita179232

Browse files
committed
vacuumdb: enable parallel mode
This mode allows vacuumdb to open several server connections to vacuumor analyze several tables simultaneously.Author: Dilip Kumar. Some reworking by Álvaro HerreraReviewed by: Jeff Janes, Amit Kapila, Magnus Hagander, Andres Freund
1 parent5cefbf5 commita179232

File tree

5 files changed

+691
-161
lines changed

5 files changed

+691
-161
lines changed

‎doc/src/sgml/ref/vacuumdb.sgml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,30 @@ PostgreSQL documentation
203203
</listitem>
204204
</varlistentry>
205205

206+
<varlistentry>
207+
<term><option>-j <replaceable class="parameter">njobs</replaceable></option></term>
208+
<term><option>--jobs=<replaceable class="parameter">njobs</replaceable></option></term>
209+
<listitem>
210+
<para>
211+
Execute the vacuum or analyze commands in parallel by running
212+
<replaceable class="parameter">njobs</replaceable>
213+
commands simultaneously. This option reduces the time of the
214+
processing but it also increases the load on the database server.
215+
</para>
216+
<para>
217+
<application>vacuumdb</application> will open
218+
<replaceable class="parameter">njobs</replaceable> connections to the
219+
database, so make sure your <xref linkend="guc-max-connections">
220+
setting is high enough to accommodate all connections.
221+
</para>
222+
<para>
223+
Note that using this mode together with the <option>-f</option>
224+
(<literal>FULL</literal>) option might cause deadlock failures if
225+
certain system catalogs are processed in parallel.
226+
</para>
227+
</listitem>
228+
</varlistentry>
229+
206230
<varlistentry>
207231
<term><option>--analyze-in-stages</option></term>
208232
<listitem>

‎src/bin/pg_dump/parallel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ select_loop(int maxFd, fd_set *workerset)
11601160
i=select(maxFd+1,workerset,NULL,NULL,NULL);
11611161

11621162
/*
1163-
* If we Ctrl-C the master process, it's likely that we interrupt
1163+
* If we Ctrl-C the master process, it's likely that we interrupt
11641164
* select() here. The signal handler will set wantAbort == true and
11651165
* the shutdown journey starts from here. Note that we'll come back
11661166
* here later when we tell all workers to terminate and read their

‎src/bin/scripts/common.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919

2020
#include"common.h"
2121

22-
staticvoidSetCancelConn(PGconn*conn);
23-
staticvoidResetCancelConn(void);
2422

2523
staticPGcancel*volatilecancelConn=NULL;
24+
boolCancelRequested= false;
2625

2726
#ifdefWIN32
2827
staticCRITICAL_SECTIONcancelConnLock;
@@ -291,7 +290,7 @@ yesno_prompt(const char *question)
291290
*
292291
* Set cancelConn to point to the current database connection.
293292
*/
294-
staticvoid
293+
void
295294
SetCancelConn(PGconn*conn)
296295
{
297296
PGcancel*oldCancelConn;
@@ -321,7 +320,7 @@ SetCancelConn(PGconn *conn)
321320
*
322321
* Free the current cancel connection, if any, and set to NULL.
323322
*/
324-
staticvoid
323+
void
325324
ResetCancelConn(void)
326325
{
327326
PGcancel*oldCancelConn;
@@ -345,9 +344,8 @@ ResetCancelConn(void)
345344

346345
#ifndefWIN32
347346
/*
348-
* Handle interrupt signals by canceling the current command,
349-
* if it's being executed through executeMaintenanceCommand(),
350-
* and thus has a cancelConn set.
347+
* Handle interrupt signals by canceling the current command, if a cancelConn
348+
* is set.
351349
*/
352350
staticvoid
353351
handle_sigint(SIGNAL_ARGS)
@@ -359,10 +357,15 @@ handle_sigint(SIGNAL_ARGS)
359357
if (cancelConn!=NULL)
360358
{
361359
if (PQcancel(cancelConn,errbuf,sizeof(errbuf)))
360+
{
361+
CancelRequested= true;
362362
fprintf(stderr,_("Cancel request sent\n"));
363+
}
363364
else
364365
fprintf(stderr,_("Could not send cancel request: %s"),errbuf);
365366
}
367+
else
368+
CancelRequested= true;
366369

367370
errno=save_errno;/* just in case the write changed it */
368371
}
@@ -392,10 +395,16 @@ consoleHandler(DWORD dwCtrlType)
392395
if (cancelConn!=NULL)
393396
{
394397
if (PQcancel(cancelConn,errbuf,sizeof(errbuf)))
398+
{
395399
fprintf(stderr,_("Cancel request sent\n"));
400+
CancelRequested= true;
401+
}
396402
else
397403
fprintf(stderr,_("Could not send cancel request: %s"),errbuf);
398404
}
405+
else
406+
CancelRequested= true;
407+
399408
LeaveCriticalSection(&cancelConnLock);
400409

401410
return TRUE;

‎src/bin/scripts/common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ enum trivalue
2121
TRI_YES
2222
};
2323

24+
externboolCancelRequested;
25+
2426
typedefvoid (*help_handler) (constchar*progname);
2527

2628
externvoidhandle_help_version_opts(intargc,char*argv[],
@@ -49,4 +51,8 @@ extern bool yesno_prompt(const char *question);
4951

5052
externvoidsetup_cancel_handler(void);
5153

54+
externvoidSetCancelConn(PGconn*conn);
55+
externvoidResetCancelConn(void);
56+
57+
5258
#endif/* COMMON_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp