vacuumlo patch

From: Tim <elatllat(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: vacuumlo patch
Date: 2011-07-24 18:48:08
Message-ID: CA+3zgmtrZW2tabW9V9Tynj8Oc9V_EnLQNpKp-zY6oHRf+pO59A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Please consider adding this minor patch, or offering improvements.

*Problem*: vacuumlo required PostgreSQL to use more locks per transaction
than possible resulting in an error and a log file full of "ignored until
end of transaction" warnings.
(max_locks_per_transaction is limited by shmmax which is limited by RAM)

*Solution*: ask vacuumlo to complete after N lo_unlink(OID)s.
*
Alternate Solution*: ask vacuumlo to start a new transaction after N
lo_unlink(OID)s.
(more complex and can be implemented with the other solution in the shell)

*Design Decisions*: Add a flag so the new behavior is optional and it
defaults to the old behavior.

*Implementation*: Followed code formatting style.
It's likely pointless to check if an int is > 2147483647 but maybe it
clarifies the code.
Added a friendly error message and the a line in the help.

git diff -U0 HEAD -- contrib/vacuumlo/vacuumlo.c
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index f6e2a28..b7c7d64 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -50,0 +51 @@ struct _param
+ int transaction_limit;
@@ -284,0 +286 @@ vacuumlo(char *database, struct _param * param)
+ {
@@ -285,0 +288,5 @@ vacuumlo(char *database, struct _param * param)
+ if(param->transaction_limit!=0 &&
deleted>=param->transaction_limit)
+ {
+ break;
+ }
+ }
@@ -315,0 +323 @@ usage(const char *progname)
+ printf(" -l LIMIT stop after removing LIMIT LOs\n");
@@ -344,0 +353 @@ main(int argc, char **argv)
+ param.transaction_limit = 0;
@@ -362 +371 @@ main(int argc, char **argv)
- c = getopt(argc, argv, "h:U:p:vnwW");
+ c = getopt(argc, argv, "h:U:p:l:vnwW");
@@ -397,0 +407,8 @@ main(int argc, char **argv)
+ case 'l':
+ param.transaction_limit = strtol(optarg, NULL, 10);
+ if ((param.transaction_limit < 0) ||
(param.transaction_limit > 2147483647))
+ {
+ fprintf(stderr, "%s: invalid transaction limit number:
%s, valid range is form 0(disabled) to 2147483647.\n", progname, optarg);
+ exit(1);
+ }
+ break;

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-07-24 18:48:31 SSL-mode error reporting in libpq
Previous Message Alvaro Herrera 2011-07-24 18:42:20 Re: Problem with pg_upgrade's directory write check on Windows