pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
113+ messages / 11 participants
[nested] [flat]
* BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
@ 2015-04-06 19:21 tgarnett@panjiva.com
2015-04-07 21:53 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-08 18:43 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Bruce Momjian <bruce@momjian.us>
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 3 replies; 113+ messages in thread
From: tgarnett@panjiva.com @ 2015-04-06 19:21 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 12990
Logged by: Timothy Garnett
Email address: tgarnett@panjiva.com
PostgreSQL version: 9.3.5
Operating system: Ubuntu Linux x86_64 12.04.5 LTS
Description:
At 4/1 5:10pm our production database started throwing these kinds of errors
(all of our hot spares were also similarly corrupted):
ERROR: could not access status of transaction 303450738
DETAIL: Could not open file "pg_multixact/members/7B49": No such file or
directory.
This is possibly related to bug 8673 (though the mailing list sounds like
most issues there were resolved by 9.3.4 and we are on 9.3.5) and also of
note this db cluster was pg_upgraded from 9.2 at one point (to 9.3.x then
further upgraded to 9.3.5)(see
http://www.postgresql.org/message-id/CAAS3ty+2ynCyf_YmRn6WuqSF8EmJMDypAkc7uD_EXTZJ7usOSg@mail.gmail....
, though it doesn't seem like that's involved here).
We have a file-system level snapshot of a hot spare of the db from about 28
hours before the errors started and sufficient wal files to do point in time
recovery. We recovered a copy of the database to about 1 hour before the
errors started and promoted that to our production db (losing a couple of
hours of commits).
Walking through the point in time recovery we see the pg_multixact/members
folder fill up and eventually suffer a massive truncation when the newest
file overtakes the oldest file. The range from oldest to newest (through the
wrap point 14078) appears to be continuous.
Time Newest-File Oldest-File
1 am 72BA 98A4(last Oct.)
10am 72BC 98A4
11am 72BD 98A4
12pm 7C4E 98A4
1 pm 7E88 98A4
2 pm 7FFF 98A4
3 pm 884E 98A4
4 pm 905F 98A4 * here we forked our new production
4:30 94AF 98D2
5pm 984D 98D2
5:15 98D2 9900 * now errors, all files outside of 98D2-9900 are gone
During the rapid growth we were generating 10-12 pg_multixact/members files
per minute.
After we forked off a new production we identified the workload that was
causing this rapid growth and stopped it. We then used vacuumdb -a -F to
vacuum freeze the whole database cluster. Our presumption was that this
would free up the members files, but it only freed up a few. The current
oldest file is 9E30 (~Jan. 1st) so moved up from 98A4 and the newest file is
906A. We're concerned this might be a time-bomb waiting for us in the
future (though at the slower growth rate of 16 files a day or so potentially
a while in the future) as the members file namespace is still 95+% consumed
post vacuum freeze. We do plan to upgrade to 9.4 sometime in the next
couple of months and are curious if we can use pg_upgrade or if we will need
to dump / restore the full (multi TiB) cluster.
As for the workload causing the rapid growth, it involved something like:
while [many millions of things to update / insert]
BEGIN;
SELECT state FROM table_A WHERE id = 1 FOR SHARE;
if state != 'blocked'
update / insert 2000-10000 rows in table_B, other stuff
COMMIT;
else
COMMIT;
sleep wait
being run in a bunch of connections (26) to the db. Row 1 of table A was
being used effectively as a share / exclusive lock as another different
process would update the state to 'blocked' to block the first process in
order to manage some shared outside the db state.
We've retained the pre-failure snapshot and wal files for now (though we
will need to free them up at some point) so we can point in time recover to
any point from 28 hours before to several hours after the problem surfaced
if that's helpful at all.
Bugs / Questions:
- the members files wrapped over themselves leading to corruption
- why didn't vacuum_db -a -F free up more members files?
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
@ 2015-04-07 21:53 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-07 22:06 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Timothy Garnett <tgarnett@panjiva.com>
2 siblings, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-04-07 21:53 UTC (permalink / raw)
To: tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
"tgarnett@panjiva.com" <tgarnett@panjiva.com> wrote:
> - why didn't vacuum_db -a -F free up more members files?
Are you sure that while the problem was developing the primary
cluster didn't have any long-running transactions (including those
left "idle in transaction" or prepared transactions)? Was there a
checkpoint following the vacuumdb -a -F run?
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-07 21:53 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-04-07 22:06 ` Timothy Garnett <tgarnett@panjiva.com>
2015-04-08 12:32 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Timothy Garnett @ 2015-04-07 22:06 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; +Cc: pgsql-bugs
>
>
> > - why didn't vacuum_db -a -F free up more members files?
>
> Are you sure that while the problem was developing the primary
> cluster didn't have any long-running transactions (including those
> left "idle in transaction" or prepared transactions)? Was there a
> checkpoint following the vacuumdb -a -F run?
The vacuum_db was run after we recovered from backup (which involved
restarting the server) so at the time the vacuum_db started there were no
open transactions. There have have been checkpoints since the vacuum_db
finished as well.
In the lead up to the problem there wouldn't have been any transactions
open more then a couple of hours (the oldest members file was over 6 months
old).
Tim
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-07 21:53 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-07 22:06 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Timothy Garnett <tgarnett@panjiva.com>
@ 2015-04-08 12:32 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-08 13:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Timothy Garnett <tgarnett@panjiva.com>
0 siblings, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-04-08 12:32 UTC (permalink / raw)
To: Timothy Garnett <tgarnett@panjiva.com>; +Cc: pgsql-bugs
Timothy Garnett <tgarnett@panjiva.com> wrote:
>>> - why didn't vacuum_db -a -F free up more members files?
>>
>> Are you sure that while the problem was developing the primary
>> cluster didn't have any long-running transactions (including
>> those left "idle in transaction" or prepared transactions)? Was
>> there a checkpoint following the vacuumdb -a -F run?
>
> The vacuum_db was run after we recovered from backup (which
> involved restarting the server) so at the time the vacuum_db
> started there were no open transactions. There have have been
> checkpoints since the vacuum_db finished as well.
>
> In the lead up to the problem there wouldn't have been any
> transactions open more then a couple of hours (the oldest members
> file was over 6 months old).
Thanks; that helps narrow where we need to look for the bug. Just
to be sure, what are the results of?:
SHOW max_prepared_transactions;
If that is non-zero, do you have any monitoring for rows in the
pg_prepared_xacts view with a "prepared" value older than some
reasonable threshold?
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-07 21:53 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-07 22:06 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Timothy Garnett <tgarnett@panjiva.com>
2015-04-08 12:32 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-04-08 13:25 ` Timothy Garnett <tgarnett@panjiva.com>
0 siblings, 0 replies; 113+ messages in thread
From: Timothy Garnett @ 2015-04-08 13:25 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; +Cc: pgsql-bugs
>
> Thanks; that helps narrow where we need to look for the bug. Just
> to be sure, what are the results of?:
>
> SHOW max_prepared_transactions;
We don't use prepared transactions so that's prob. not involved.
SHOW max_prepared_transactions;
max_prepared_transactions
---------------------------
0
(1 row)
Tim
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
@ 2015-04-08 18:43 ` Bruce Momjian <bruce@momjian.us>
2 siblings, 0 replies; 113+ messages in thread
From: Bruce Momjian @ 2015-04-08 18:43 UTC (permalink / raw)
To: tgarnett@panjiva.com; +Cc: pgsql-bugs
On Mon, Apr 6, 2015 at 07:21:30PM +0000, tgarnett@panjiva.com wrote:
> We've retained the pre-failure snapshot and wal files for now (though we
> will need to free them up at some point) so we can point in time recover to
> any point from 28 hours before to several hours after the problem surfaced
> if that's helpful at all.
>
> Bugs / Questions:
> - the members files wrapped over themselves leading to corruption
> - why didn't vacuum_db -a -F free up more members files?
Wow, you did a lot of research on this and I am glad you seem to have
found a solution. Frankly, there were so many multi-xact bugs in 9.3.X
that I am unable to track exactly what bugs caused what failures, when
they were fixed, and whether fixes fixed the problem for good, or
whether they just fixed them from happening in the future. Yes, very
discouraging.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
@ 2015-04-13 21:08 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-15 16:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2 siblings, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-13 21:08 UTC (permalink / raw)
To: tgarnett@panjiva.com; +Cc: pgsql-bugs
tgarnett@panjiva.com wrote:
> ERROR: could not access status of transaction 303450738
> DETAIL: Could not open file "pg_multixact/members/7B49": No such file or
> directory.
Bruce and Kevin both pinged me about this issue recently. Turns out
that I have an incomplete patch to close the problem. Just to clarify,
this is a completely new problem, not related to #8673.
The fix is to raise an ERROR when generating a new multixact, if we
detect that doing so would get close to the oldest multixact that the
system knows about. If that happens, the solution is to vacuum so that
the "oldest" point is advanced a bit more and you have room to generate
more multixacts. In production, you would typically adjust the
multixact freeze parameters so that "oldest multixact" is advanced more
aggressively and you don't hit the ERROR.
A fix I pushed to master (for a performance regression reportes as bug
#8470) would make the problem less common, by having typical multixact
sizes be smaller. I didn't backpatch that fix due to lack of feedback,
but since it is connected to this data-eating bug, maybe we should look
into doing so. This problem only arises if your multixacts are larger
than 24 members in average (or something like that. I don't recall the
exact number.) That should be atypical, except that prior to the #8470
fix the multixact size is related to number of subtransactions doing
certain operations in a loop.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-15 16:04 ` Robert Haas <robertmhaas@gmail.com>
2015-04-16 20:33 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Timothy Garnett <tgarnett@panjiva.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-04-15 16:04 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Mon, Apr 13, 2015 at 5:08 PM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> tgarnett@panjiva.com wrote:
>
>> ERROR: could not access status of transaction 303450738
>> DETAIL: Could not open file "pg_multixact/members/7B49": No such file or
>> directory.
>
> Bruce and Kevin both pinged me about this issue recently. Turns out
> that I have an incomplete patch to close the problem. Just to clarify,
> this is a completely new problem, not related to #8673.
>
> The fix is to raise an ERROR when generating a new multixact, if we
> detect that doing so would get close to the oldest multixact that the
> system knows about.
I think we definitely need to do that ASAP. And possibly then force
an immediate minor release. Bugs that eat your data are bad, and we
have a customer hitting this completely independently of this report,
which makes this look like more than a theoretical problem.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-15 16:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-16 20:33 ` Timothy Garnett <tgarnett@panjiva.com>
0 siblings, 0 replies; 113+ messages in thread
From: Timothy Garnett @ 2015-04-16 20:33 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
On Wed, Apr 15, 2015 at 12:04 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> I think we definitely need to do that ASAP. And possibly then force
> an immediate minor release. Bugs that eat your data are bad, and we
> have a customer hitting this completely independently of this report,
> which makes this look like more than a theoretical problem.
>
>
I defer to others on what a good timeline would be, but failing harder here
would be good. We were somewhat lucky in discovering the issue as fast as
we did. Post wrap, 99.9+% of the queries to our database were returning
fine without error. We only observed the failure when accessing two
specific rows in two different tables (there were possibly more, it's a
multi-TiB db cluster). Had we not hit those rows for a few days instead of
a few hours recovery would have been extremely difficult as rolling back to
a known good state wouldn't have really been an option.
Tim
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-20 19:04 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-21 05:12 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
1 sibling, 3 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-20 19:04 UTC (permalink / raw)
To: tgarnett@panjiva.com; +Cc: pgsql-bugs; kgrittn@ymail.com
Alvaro Herrera wrote:
> The fix is to raise an ERROR when generating a new multixact, if we
> detect that doing so would get close to the oldest multixact that the
> system knows about. If that happens, the solution is to vacuum so that
> the "oldest" point is advanced a bit more and you have room to generate
> more multixacts. In production, you would typically adjust the
> multixact freeze parameters so that "oldest multixact" is advanced more
> aggressively and you don't hit the ERROR.
Here's a patch. I have tested locally and it closes the issue for me.
If those affected can confirm that it stops the file removal from
happening, I'd appreciate it.
It would be much better to avoid that additional file reading, but it
seems difficult (read: I don't see how) without changing pg_control.
Note: in bootstrap.c, I had to move setting the bootstrap a bit earlier.
Otherwise, the is-in-bootstrap mode test returned false while
bootstrapping multixact, so initdb would fail on the initial phase
because of trying to read pg_multixact/offset/0000 which hasn't been
created at that point. The amount of code that runs in the bootstrap
mode after this change that wasn't running in bootstrap mode previously
is pretty tiny and shouldn't cause any problem -- it's essentially
the whole of BootStrapXLOG().
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap.patch (text/x-diff, 8.7K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index d13d2e7..488a49a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -211,6 +211,10 @@ typedef struct MultiXactStateData
MultiXactId multiStopLimit;
MultiXactId multiWrapLimit;
+ /* support for members anti-wraparound measures */
+ MultiXactOffset offsetWarnLimit;
+ MultiXactOffset offsetStopLimit;
+
/*
* Per-backend data starts here. We have two arrays stored in the area
* immediately following the MultiXactStateData struct. Each is indexed by
@@ -339,6 +343,8 @@ static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers);
+static MultiXactOffset read_offset_for_multi(MultiXactId multi);
+static void DetermineSafeOldestOffset(MultiXactId oldestMXact);
static void WriteMZeroPageXlogRec(int pageno, uint8 info);
@@ -975,7 +981,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
/*
* To avoid swamping the postmaster with signals, we issue the autovac
- * request only once per 64K transaction starts. This still gives
+ * request only once per 64K multis generated. This still gives
* plenty of chances before we get into real trouble.
*/
if (IsUnderPostmaster && (result % 65536) == 0)
@@ -1051,6 +1057,36 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
else
*offset = nextOffset;
+ /*
+ * Protect against overrun of the members space as well, with the following
+ * rules:
+ *
+ * - if we're past offsetWarnLimit, emit a warning.
+ * - if we're past offsetStopLimit, refuse to generate more multis.
+ *
+ * Note we haven't updated the shared state yet, so if we fail at this
+ * point, the multixact ID we grabbed can still be used by the next guy.
+ *
+ * Note that thre is no point in forcing autovacuum runs here; the
+ * multixact freeze settings would have to be reduced for that to have any
+ * effect, and we can't do that from here.
+ */
+ if (MultiXactOffsetPrecedes(MultiXactState->offsetStopLimit, nextOffset + nmembers))
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("database is not accepting commands that generate new MultiXactIds to avoid \"members\" wraparound data loss in database with OID %u",
+ MultiXactState->oldestMultiXactDB),
+ errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
+ else if (MultiXactOffsetPrecedes(MultiXactState->offsetWarnLimit, nextOffset + nmembers))
+ ereport(WARNING,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg_plural("database with OID %u must be vacuumed before %d more multixact member is used",
+ "database with OID %u must be vacuumed before %d more multixact members are used",
+ MultiXactState->offsetStopLimit - nextOffset + nmembers,
+ MultiXactState->oldestMultiXactDB,
+ MultiXactState->offsetStopLimit - nextOffset + nmembers),
+ errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
+
ExtendMultiXactMember(nextOffset, nmembers);
/*
@@ -1921,6 +1957,12 @@ StartupMultiXact(void)
*/
pageno = MXOffsetToMemberPage(offset);
MultiXactMemberCtl->shared->latest_page_number = pageno;
+
+ /*
+ * compute the oldest member we need to keep around to avoid old member
+ * data overrun.
+ */
+ DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
/*
@@ -2121,7 +2163,7 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
*
* Note: This differs from the magic number used in
* SetTransactionIdLimit() since vacuum itself will never generate new
- * multis.
+ * multis. XXX actually it does, if it needs to freeze old multis.
*/
multiStopLimit = multiWrapLimit - 100;
if (multiStopLimit < FirstMultiXactId)
@@ -2164,6 +2206,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
curMulti = MultiXactState->nextMXact;
LWLockRelease(MultiXactGenLock);
+ DetermineSafeOldestOffset(oldest_datminmxid);
+
/* Log the info */
ereport(DEBUG1,
(errmsg("MultiXactId wrap limit is %u, limited by database with OID %u",
@@ -2250,13 +2294,16 @@ MultiXactAdvanceNextMXact(MultiXactId minMulti,
/*
* Update our oldestMultiXactId value, but only if it's more recent than
- * what we had.
+ * what we had. However, even if not, always update the oldest multixact
+ * offset limit.
*/
void
MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
+ else
+ DetermineSafeOldestOffset(oldestMulti);
}
/*
@@ -2424,6 +2471,70 @@ GetOldestMultiXactId(void)
}
/*
+ * Read the offset of the first member of the given multixact.
+ */
+static MultiXactOffset
+read_offset_for_multi(MultiXactId multi)
+{
+ MultiXactOffset offset;
+ int pageno;
+ int entryno;
+ int slotno;
+ MultiXactOffset *offptr;
+
+ pageno = MultiXactIdToOffsetPage(multi);
+ entryno = MultiXactIdToOffsetEntry(multi);
+
+ /* lock is acquired by SimpleLruReadPage_ReadOnly */
+ slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+ offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
+ offptr += entryno;
+ offset = *offptr;
+ LWLockRelease(MultiXactOffsetControlLock);
+
+ return offset;
+}
+
+/*
+ * Based on the given oldest MultiXactId, determine what's the oldest member
+ * offset and install the limit info in MultiXactState, where it can be used to
+ * prevent overrun of old data in the members SLRU area.
+ */
+static void
+DetermineSafeOldestOffset(MultiXactId oldestMXact)
+{
+ MultiXactOffset oldestOffset;
+
+ /*
+ * Can't do this while initdb'ing or in the startup process while replaying
+ * WAL: the segment file to read might have not yet been created, or
+ * already been removed.
+ */
+ if (IsBootstrapProcessingMode() || InRecovery)
+ return;
+
+ /*
+ * We determine the safe upper bound for offsets of new xacts by reading
+ * the offset of the oldest multixact, and going back one segment. This
+ * way, the sequence of multixact member segments will always have a
+ * one-segment hole at a minimum. We start spewing warnings 19 segments
+ * before that.
+ */
+ oldestOffset = read_offset_for_multi(oldestMXact);
+ /* move back to start of this segment */
+ oldestOffset -= oldestOffset / MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT;
+
+ LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
+ /* always leave one segment before the wraparound point */
+ MultiXactState->offsetStopLimit = oldestOffset -
+ (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ /* start complaining 20 segments before the wraparound point */
+ MultiXactState->offsetWarnLimit = oldestOffset -
+ (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT * 20);
+ LWLockRelease(MultiXactGenLock);
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
@@ -2555,26 +2666,7 @@ TruncateMultiXact(void)
* First, compute the safe truncation point for MultiXactMember. This is
* the starting offset of the oldest multixact.
*/
- {
- int pageno;
- int slotno;
- int entryno;
- MultiXactOffset *offptr;
-
- /* lock is acquired by SimpleLruReadPage_ReadOnly */
-
- pageno = MultiXactIdToOffsetPage(oldestMXact);
- entryno = MultiXactIdToOffsetEntry(oldestMXact);
-
- slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
- oldestMXact);
- offptr = (MultiXactOffset *)
- MultiXactOffsetCtl->shared->page_buffer[slotno];
- offptr += entryno;
- oldestOffset = *offptr;
-
- LWLockRelease(MultiXactOffsetControlLock);
- }
+ oldestOffset = read_offset_for_multi(oldestMXact);
/*
* To truncate MultiXactMembers, we need to figure out the active page
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index fc1b3c8..43a50e4 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -411,6 +411,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
proc_exit(1); /* should never return */
case BootstrapProcess:
+ SetProcessingMode(BootstrapProcessing);
bootstrap_signals();
BootStrapXLOG();
BootstrapModeMain();
@@ -473,8 +474,7 @@ BootstrapModeMain(void)
int i;
Assert(!IsUnderPostmaster);
-
- SetProcessingMode(BootstrapProcessing);
+ Assert(IsBootstrapProcessingMode());
/*
* Do backend-like initialization for bootstrap mode
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-21 00:25 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-04-21 00:25 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: tgarnett@panjiva.com; pgsql-bugs; kgrittn@ymail.com
Hi Alvaro
On Tue, Apr 21, 2015 at 7:04 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Here's a patch. I have tested locally and it closes the issue for me.
> If those affected can confirm that it stops the file removal from
> happening, I'd appreciate it.
I was also starting to look at this problem. For what it's worth,
here's a client program that I used to generate a lot of multixact
members. The patch seems to work correctly so far: as the offset
approached wraparound, I saw the warnings first with appropriate OID
and members remaining, and then I was blocked from creating new
multixacts.
Best regards,
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
explode_mxact_members.c (text/x-csrc, 1.9K) download
#include <libpq-fe.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
/*
* A quick and dirty way to generate a lot of pg_multixact/members segments.
* First, CREATE TABLE foo AS SELECT 42. Then run with two numeric arguments:
* sessions (= number of connections) and loops (= number of repetitions).
*
* Each loop should generate sessions multixacts (because each session that
* share-locks the row creates a new multixact) and sessions * (sessions - 1)
* / 2 member entries (because each multixact created gets all the members
* from the previous one plus the new one, so we finish up with a total of 1 +
* 2 + ... + sessions member entries per loop, a triangular number, probably
* order n^2).
*
* On my Mac laptop, run with 500 100000 (after increasing max_connections and
* shared_buffers appropriately), this generates 2^32 multixact members in
* under a couple of hours.
*/
int main(int argc, char **argv)
{
int i;
int sessions;
int loop;
int loops;
PGconn **conns;
PGresult *res;
const char *conninfo = "dbname = postgres";
assert(argc == 3);
sessions = atoi(argv[1]);
loops = atoi(argv[2]);
conns = malloc(sizeof(PGconn *) * sessions);
assert(conns);
for (i = 0; i < sessions; ++i)
{
conns[i] = PQconnectdb(conninfo);
assert(PQstatus(conns[i]) == CONNECTION_OK);
}
printf("%d sessions connected...\n", sessions);
for (loop = 0; loop < loops; ++loop)
{
printf("Loop %d...\n", loop);
for (i = 0; i < sessions; ++i)
{
res = PQexec(conns[i], "BEGIN");
assert(PQresultStatus(res) == PGRES_COMMAND_OK);
res = PQexec(conns[i], "SELECT * FROM foo WHERE id = 42 FOR SHARE");
assert(PQresultStatus(res) == PGRES_TUPLES_OK);
PQclear(res);
}
for (i = 0; i < sessions; ++i)
{
res = PQexec(conns[i], "ROLLBACK");
assert(PQresultStatus(res) == PGRES_COMMAND_OK);
PQclear(res);
}
}
for (i = 0; i < sessions; ++i)
{
PQfinish(conns[i]);
}
printf("Disconnected.\n");
free(conns);
return 0;
}
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-04-23 05:25 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-04-23 05:25 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; kgrittn@ymail.com
On Tue, Apr 21, 2015 at 12:25 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Hi Alvaro
>
> On Tue, Apr 21, 2015 at 7:04 AM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:
>> Here's a patch. I have tested locally and it closes the issue for me.
>> If those affected can confirm that it stops the file removal from
>> happening, I'd appreciate it.
>
> I was also starting to look at this problem. For what it's worth,
> here's a client program that I used to generate a lot of multixact
> members. The patch seems to work correctly so far: as the offset
> approached wraparound, I saw the warnings first with appropriate OID
> and members remaining, and then I was blocked from creating new
> multixacts.
One thing I noticed about your patch is that it effectively halves the
amount of multixact members you can have on disk. Sure, I'd rather
hit an error at 2^31 members than a corrupt database at 2^32 members,
but I wondered if we should try to allow the full range to be used.
I'm not sure whether there is a valid use case for such massive
amounts of pg_multixact/members data (or at least one that won't go
away if autovacuum heuristics are changed in a later patch, also I
understand that there are other recent patches that reduce member
traffic), but I if the plan is to backpatch this patch then I suppose
it should ideally not halve the amount of an important resource you
can use in existing system when people do a point upgrade.
Here's a small patch (that applies after your patch) to show how this
could be done, using three-way comparisons with an explicit boundary
to detect wraparound. There may be other technical problems (for
example MultiXactAdvanceNextMXact still uses the
MultiXactOffsetPrecedes), or this may be a bad idea just because it
breaks with the well convention for wrap around detection established
by xids.
Also, I wanted to make sure I could reproduce the original
bug/corruption in unpatched master with the client program I posted.
Here are my notes on doing that (sorry if they belabour the obvious,
partly this is just me learning how SLRUs and multixacts work...):
========
Member wraparound happens after segment file "14078" (assuming default
page size, you get 32 pages per segment, and 1636 members per page
(409 groups of 4 + some extra data), and our max member offset wraps
after 0xffffffff, and 0xffffffff / 1636 / 32 = 82040 = 0x14078;
incidentally that final segment is a shorter one).
Using my test client with 500 sessions and 35k loops I observed this,
it wrapped back around to writing to member file "0000" after creating
"14078", which is obviously broken, because the start of member
segment "0000" holds members for multixact ID 1, which was still in
play (it was datminmxid for template0).
Looking at the members of multixact ID 1 I see recent xids:
postgres=# select pg_get_multixact_members('1'::xid);
pg_get_multixact_members
--------------------------
(34238661,sh)
(34238662,sh)
(2 rows)
Note that pg_get_multixact_members knows the correct *number* of
members for multixact ID 1, it's just that it's looking at members
from some much later multixact. By a tedious binary search I found
it:
postgres=# select pg_get_multixact_members('17094780'::xid);
pg_get_multixact_members
--------------------------
... snip ...
(34238660,sh)
(34238661,sh) <-- here they are!
(34238662,sh) <--
(34238663,sh)
... snip ...
After a checkpoint, I saw that all the files got deleted except for a
few consecutively named files starting at "0000", which would be
correct behavior in general, if we hadn't allowed the member offset to
wrap. It had correctly kept the segments starting with the one
holding the members of multixact ID 1 (the cluster-wide oldest) up
until the one that corresponds to MultiXactState->nextOffset. My test
program had blown right past member offset 0xffffffff and back to 0
and then kept going. The truncation code isn't the problem per se.
To produce the specific error message seen by the bug reporter via
normal interactions from a test program, I think we need some magic
that I can't figure out how to do yet: we need to run a query that
accesses a multixact that has member offset from before offset
wraparound, eg 0xffffffff or similar, but whose members are not on a
page that is still in memory, after a checkpoint that has unlinked the
segment file, so it can try to load it and discover that the segment
file is missing! So a pretty complex interaction of concurrent
processes, timing and caches.
We can more artificially stimulate the error by explicitly asking for
multixact members like this though:
postgres=# select pg_get_multixact_members('10000000'::xid);
ERROR: could not access status of transaction 10000000
DETAIL: Could not open file "pg_multixact/members/BB55": No such file
or directory.
That's a totally valid multixact ID, obviously since it's been able to
figure out which segment to look in for its members.
Here's one that tries to open the segment that comes immediately
before "0000" in modulo numbering:
postgres=# select pg_get_multixact_members('17094770'::xid);
ERROR: could not access status of transaction 17094770
DETAIL: Could not open file "pg_multixact/members/14078": No such
file or directory.
If I tried it with 17094779, the multixact ID immediatly before the
one that has overwritten "0000", it does actually work, presumably
because its pages happen to be buffered for me so it doesn't try to
open the file (guessing here).
I don't currently believe it's necessary to reproduce that step via a
test program anyway, the root problem is clear enough just from
watching the thing wrap.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-full-range.patch (application/octet-stream, 2.2K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 03ca079..25958aa 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -908,6 +908,37 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
}
/*
+ * Check if we could add "distance" to "start", without moving past
+ * "boundary", using modulo arithmetic.
+ */
+static bool
+MultiXactOffsetWouldWrap(MultiXactOffset boundary,
+ MultiXactOffset start,
+ int distance)
+{
+ MultiXactOffset finish = start + distance;
+ Assert(distance >= 0);
+ if (start < boundary)
+ /*
+ * <----S----B---->
+ *
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [---) = F OK
+ * [----] = F wrapped past B
+ */
+ return finish >= boundary || finish < start;
+ else
+ /*
+ * <----B----S---->
+ *
+ * [---) = F OK
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [----] = F OK
+ */
+ return finish >= boundary && finish < start;
+}
+
+/*
* GetNewMultiXactId
* Get the next MultiXactId.
*
@@ -1063,13 +1094,13 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* multixact freeze settings would have to be reduced for that to have any
* effect, and we can't do that from here.
*/
- if (MultiXactOffsetPrecedes(MultiXactState->offsetStopLimit, nextOffset + nmembers))
+ if (MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit, nextOffset, nmembers))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("database is not accepting commands that generate new MultiXactIds to avoid \"members\" wraparound data loss in database with OID %u",
MultiXactState->oldestMultiXactDB),
errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
- else if (MultiXactOffsetPrecedes(MultiXactState->offsetWarnLimit, nextOffset + nmembers))
+ else if (MultiXactOffsetWouldWrap(MultiXactState->offsetWarnLimit, nextOffset, nmembers))
ereport(WARNING,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg_plural("database with OID %u must be vacuumed before %d more multixact member is used",
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-04-28 06:23 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-28 06:23 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; kgrittn@ymail.com
Thomas Munro wrote:
> One thing I noticed about your patch is that it effectively halves the
> amount of multixact members you can have on disk. Sure, I'd rather
> hit an error at 2^31 members than a corrupt database at 2^32 members,
> but I wondered if we should try to allow the full range to be used.
Ah, yeah, we do want the full range; that's already built in the code
elsewhere.
In this version, I used your WouldWrap function, but there was a bug in
your formulation of the call site: after the WARNING has been issued
once, it is never issued again for that wraparound cycle, because the
second time around the nextOffset has already crossed the boundary and
your routine returns false. IMO this is wrong and the warning should be
issued every time. To fix that problem I removed the offsetWarnLimit
altogether, and instead do WouldWrap() of the value against
offsetStopLimit minus the 20 segments. That way, the warning is issued
continuously until the offsetStopLimit is reached (once there,
obviously, only the error is thrown, not the warning, which is correct.)
I also added a call to DetermineSafeOldestOffset() in TrimMultiXact:
as far as I can tell, this is necessary for the time when a standby
exits recovery, because when InRecovery we return early from
DetermineSafeOldestOffset() so the safe point would never get set.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-2.patch (text/x-diff, 11.1K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 3dd9892..12da9f0 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -211,6 +211,9 @@ typedef struct MultiXactStateData
MultiXactId multiStopLimit;
MultiXactId multiWrapLimit;
+ /* support for members anti-wraparound measures */
+ MultiXactOffset offsetStopLimit;
+
/*
* Per-backend data starts here. We have two arrays stored in the area
* immediately following the MultiXactStateData struct. Each is indexed by
@@ -339,6 +342,10 @@ static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers);
+static void DetermineSafeOldestOffset(MultiXactId oldestMXact);
+static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
+ MultiXactOffset start, uint32 distance);
+static MultiXactOffset read_offset_for_multi(MultiXactId multi);
static void WriteMZeroPageXlogRec(int pageno, uint8 info);
@@ -972,7 +979,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
/*
* To avoid swamping the postmaster with signals, we issue the autovac
- * request only once per 64K transaction starts. This still gives
+ * request only once per 64K multis generated. This still gives
* plenty of chances before we get into real trouble.
*/
if (IsUnderPostmaster && (result % 65536) == 0)
@@ -1048,6 +1055,46 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
else
*offset = nextOffset;
+ /*
+ * Protect against overrun of the members space as well, with the following
+ * rules:
+ *
+ * - if we're past offsetStopLimit, refuse to generate more multis.
+ * - if we're close to offsetStopLimit, emit a warning.
+ *
+ * Arbitrarily, we start emitting warnings when we're 20 segments or less
+ * from offsetStopLimit.
+ *
+ * Note we haven't updated the shared state yet, so if we fail at this
+ * point, the multixact ID we grabbed can still be used by the next guy.
+ *
+ * Note that there is no point in forcing autovacuum runs here: the
+ * multixact freeze settings would have to be reduced for that to have any
+ * effect.
+ */
+#define OFFSET_WARN_SEGMENTS 20
+ if (MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit, nextOffset,
+ nmembers))
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("multixact \"members\" limit exceeded"),
+ errdetail_plural("This command would create a multixact with %u members, which exceeds remaining space (%u member.)",
+ "This command would create a multixact with %u members, which exceeds remaining space (%u members.)",
+ MultiXactState->offsetStopLimit - nextOffset - 1,
+ nmembers,
+ MultiXactState->offsetStopLimit - nextOffset - 1),
+ errhint("Execute a database-wide VACUUM in database with OID %u, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.",
+ MultiXactState->oldestMultiXactDB)));
+ else if (MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit,
+ nextOffset,
+ nmembers + MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT * OFFSET_WARN_SEGMENTS))
+ ereport(WARNING,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("database with OID %u must be vacuumed before %d more multixact members are used",
+ MultiXactState->oldestMultiXactDB,
+ MultiXactState->offsetStopLimit - nextOffset + nmembers),
+ errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
+
ExtendMultiXactMember(nextOffset, nmembers);
/*
@@ -1918,6 +1965,12 @@ StartupMultiXact(void)
*/
pageno = MXOffsetToMemberPage(offset);
MultiXactMemberCtl->shared->latest_page_number = pageno;
+
+ /*
+ * compute the oldest member we need to keep around to avoid old member
+ * data overrun.
+ */
+ DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
/*
@@ -2011,6 +2064,8 @@ TrimMultiXact(void)
}
LWLockRelease(MultiXactMemberControlLock);
+
+ DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
/*
@@ -2118,7 +2173,7 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
*
* Note: This differs from the magic number used in
* SetTransactionIdLimit() since vacuum itself will never generate new
- * multis.
+ * multis. XXX actually it does, if it needs to freeze old multis.
*/
multiStopLimit = multiWrapLimit - 100;
if (multiStopLimit < FirstMultiXactId)
@@ -2161,6 +2216,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
curMulti = MultiXactState->nextMXact;
LWLockRelease(MultiXactGenLock);
+ DetermineSafeOldestOffset(oldest_datminmxid);
+
/* Log the info */
ereport(DEBUG1,
(errmsg("MultiXactId wrap limit is %u, limited by database with OID %u",
@@ -2247,13 +2304,16 @@ MultiXactAdvanceNextMXact(MultiXactId minMulti,
/*
* Update our oldestMultiXactId value, but only if it's more recent than
- * what we had.
+ * what we had. However, even if not, always update the oldest multixact
+ * offset limit.
*/
void
MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
+ else
+ DetermineSafeOldestOffset(oldestMulti);
}
/*
@@ -2421,6 +2481,121 @@ GetOldestMultiXactId(void)
}
/*
+ * Based on the given oldest MultiXactId, determine what's the oldest member
+ * offset and install the limit info in MultiXactState, where it can be used to
+ * prevent overrun of old data in the members SLRU area.
+ */
+static void
+DetermineSafeOldestOffset(MultiXactId oldestMXact)
+{
+ MultiXactOffset oldestOffset;
+
+ /*
+ * Can't do this while initdb'ing or in the startup process while replaying
+ * WAL: the segment file to read might have not yet been created, or
+ * already been removed.
+ */
+ if (IsBootstrapProcessingMode() || InRecovery)
+ return;
+
+ /*
+ * We determine the safe upper bound for offsets of new xacts by reading
+ * the offset of the oldest multixact, and going back one segment. This
+ * way, the sequence of multixact member segments will always have a
+ * one-segment hole at a minimum. We start spewing warnings a few complete
+ * segments before that.
+ */
+ oldestOffset = read_offset_for_multi(oldestMXact);
+ /* move back to start of the corresponding segment */
+ oldestOffset -= oldestOffset / MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT;
+
+ LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
+ /* always leave one segment before the wraparound point */
+ MultiXactState->offsetStopLimit = oldestOffset -
+ (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ LWLockRelease(MultiXactGenLock);
+}
+
+/*
+ * Return whether adding "distance" to "start" would move past "boundary".
+ *
+ * We use this to determine whether the addition is "wrapping around" the
+ * boundary point, hence the name. The reason we don't want to use the regular
+ * 2^31-modulo arithmetic here is that we want to be able to use the whole of
+ * the 2^32-1 space here, allowing for more multixacts that would fit
+ * otherwise. See also SlruScanDirCbRemoveMembers.
+ */
+static bool
+MultiXactOffsetWouldWrap(MultiXactOffset boundary, MultiXactOffset start,
+ uint32 distance)
+{
+ MultiXactOffset finish;
+
+ Assert(distance >= 0);
+
+ /*
+ * Note that offset number 0 is not used (see GetMultiXactIdMembers), so if
+ * the addition wraps around the UINT_MAX boundary, skip that value.
+ */
+ finish = start + distance;
+ if (finish < start)
+ finish++;
+
+ /*-----------------------------------------------------------------------
+ * When the boundary is numerically greater than the starting point, any
+ * value numerically between the two is not wrapped:
+ *
+ * <----S----B---->
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [---) = F not wrapped
+ * [----] = F wrapped past B
+ *
+ * When the boundary is numerically less than the starting point (i.e. the
+ * UINT_MAX wraparound occurs somewhere in between) then all values in
+ * between are wrapped:
+ *
+ * <----B----S---->
+ * [---) = F not wrapped past B (but wrapped past UINT_MAX)
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [----] = F not wrapped
+ *-----------------------------------------------------------------------
+ */
+ if (start < boundary)
+ {
+ return finish >= boundary || finish < start;
+ }
+ else
+ {
+ return finish >= boundary && finish < start;
+ }
+}
+
+/*
+ * Read the offset of the first member of the given multixact.
+ */
+static MultiXactOffset
+read_offset_for_multi(MultiXactId multi)
+{
+ MultiXactOffset offset;
+ int pageno;
+ int entryno;
+ int slotno;
+ MultiXactOffset *offptr;
+
+ pageno = MultiXactIdToOffsetPage(multi);
+ entryno = MultiXactIdToOffsetEntry(multi);
+
+ /* lock is acquired by SimpleLruReadPage_ReadOnly */
+ slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+ offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
+ offptr += entryno;
+ offset = *offptr;
+ LWLockRelease(MultiXactOffsetControlLock);
+
+ return offset;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
@@ -2552,26 +2727,7 @@ TruncateMultiXact(void)
* First, compute the safe truncation point for MultiXactMember. This is
* the starting offset of the oldest multixact.
*/
- {
- int pageno;
- int slotno;
- int entryno;
- MultiXactOffset *offptr;
-
- /* lock is acquired by SimpleLruReadPage_ReadOnly */
-
- pageno = MultiXactIdToOffsetPage(oldestMXact);
- entryno = MultiXactIdToOffsetEntry(oldestMXact);
-
- slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
- oldestMXact);
- offptr = (MultiXactOffset *)
- MultiXactOffsetCtl->shared->page_buffer[slotno];
- offptr += entryno;
- oldestOffset = *offptr;
-
- LWLockRelease(MultiXactOffsetControlLock);
- }
+ oldestOffset = read_offset_for_multi(oldestMXact);
/*
* To truncate MultiXactMembers, we need to figure out the active page
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index fc1b3c8..5c0fe9b 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -411,6 +411,12 @@ AuxiliaryProcessMain(int argc, char *argv[])
proc_exit(1); /* should never return */
case BootstrapProcess:
+ /*
+ * There was a brief instant during which mode was Normal; this is
+ * okay. We need to be in bootstrap mode during BootStrapXLOG for
+ * the sake of multixact initialization.
+ */
+ SetProcessingMode(BootstrapProcessing);
bootstrap_signals();
BootStrapXLOG();
BootstrapModeMain();
@@ -473,8 +479,7 @@ BootstrapModeMain(void)
int i;
Assert(!IsUnderPostmaster);
-
- SetProcessingMode(BootstrapProcessing);
+ Assert(IsBootstrapProcessingMode());
/*
* Do backend-like initialization for bootstrap mode
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-28 06:30 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 14:35 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 2 replies; 113+ messages in thread
From: Thomas Munro @ 2015-04-28 06:30 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 6:23 PM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Thomas Munro wrote:
>
>> One thing I noticed about your patch is that it effectively halves the
>> amount of multixact members you can have on disk. Sure, I'd rather
>> hit an error at 2^31 members than a corrupt database at 2^32 members,
>> but I wondered if we should try to allow the full range to be used.
>
> Ah, yeah, we do want the full range; that's already built in the code
> elsewhere.
>
> In this version, I used your WouldWrap function, but there was a bug in
> your formulation of the call site: after the WARNING has been issued
> once, it is never issued again for that wraparound cycle, because the
> second time around the nextOffset has already crossed the boundary and
> your routine returns false. IMO this is wrong and the warning should be
> issued every time. To fix that problem I removed the offsetWarnLimit
> altogether, and instead do WouldWrap() of the value against
> offsetStopLimit minus the 20 segments. That way, the warning is issued
> continuously until the offsetStopLimit is reached (once there,
> obviously, only the error is thrown, not the warning, which is correct.)
+1
Tomorrow I will send a separate patch for the autovacuum changes that
I sent earlier. Let's discuss and hopefully eventually commit that
separately.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-04-28 14:35 ` Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-28 14:35 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Thomas Munro wrote:
> > In this version, I used your WouldWrap function, [...]
>
> +1
Pushed.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-04-29 00:14 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
1 sibling, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-04-29 00:14 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 6:30 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Tomorrow I will send a separate patch for the autovacuum changes that
> I sent earlier. Let's discuss and hopefully eventually commit that
> separately.
Here is a separate patch which makes autovacuum start a wrap-around
vacuum sooner if the member space is running out, by adjusting
autovacuum_multixact_freeze_max_age using a progressive scaling
factor. This version includes a clearer implementation of
autovacuum_multixact_freeze_max_age_adjusted provided by Kevin
Grittner off-list.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-autovacuum.patch (application/octet-stream, 5.9K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index c8faa17..634224b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2574,6 +2574,29 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of members in the
+ * members SLRU area.
+ */
+MultiXactOffset
+ReadMultiXactMemberCount(void)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * TODO: In future, could oldestMultiXactMemberOffset be stored in shmem,
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ return nextOffset - oldestOffset;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..3502a7f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -601,7 +601,7 @@ vacuum_set_xid_limits(Relation rel,
if (freezetable < 0)
freezetable = vacuum_multixact_freeze_table_age;
freezetable = Min(freezetable,
- autovacuum_multixact_freeze_max_age * 0.95);
+ autovacuum_multixact_freeze_max_age_adjusted() * 0.95);
Assert(freezetable >= 0);
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..9848ce7 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1052,6 +1052,39 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Returns vacuum_multixact_freeze_max_age, adjusted down to prevent excessive use
+ * of addressable multixact member space if required.
+ *
+ * The goal is to avoid the situation where new multixacts can't be created
+ * because the offsets used to address pg_multixact/members would wrap around.
+ *
+ * If less than "minimum safe member count" of the total available member
+ * space is used, then we make no adjustment (this should apply to most
+ * typical users). If more than the "max safe member count" of the total
+ * available member space is used, then we use a freeze max age of zero to
+ * trigger aggressive vacuuming. In between, we scale the given freeze max
+ * age down linearly, so that vacuuming becomes more aggressive as the member
+ * SLRU grows.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we just define constants at 25% and 75%.
+ */
+#define MIN_SAFE_MEMBER_COUNT (MaxMultiXactOffset / 4)
+#define MAX_SAFE_MEMBER_COUNT (MaxMultiXactOffset - MIN_SAFE_MEMBER_COUNT)
+int
+autovacuum_multixact_freeze_max_age_adjusted()
+{
+ MultiXactOffset mxact_member_count = ReadMultiXactMemberCount();
+ if (mxact_member_count <= MIN_SAFE_MEMBER_COUNT)
+ return autovacuum_multixact_freeze_max_age;
+ else if (mxact_member_count >= MAX_SAFE_MEMBER_COUNT)
+ return 0;
+ else return (int) (autovacuum_multixact_freeze_max_age
+ * (((double) (MAX_SAFE_MEMBER_COUNT - mxact_member_count))
+ / ((double) (MAX_SAFE_MEMBER_COUNT - MIN_SAFE_MEMBER_COUNT))));
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1118,7 +1151,7 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age_adjusted();
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1931,7 +1964,9 @@ do_autovacuum(void)
{
default_freeze_min_age = vacuum_freeze_min_age;
default_freeze_table_age = vacuum_freeze_table_age;
- default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
+ default_multixact_freeze_min_age =
+ Min(vacuum_multixact_freeze_min_age,
+ autovacuum_multixact_freeze_max_age_adjusted());
default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
}
@@ -2684,8 +2719,8 @@ relation_needs_vacanalyze(Oid relid,
: autovacuum_freeze_max_age;
multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age >= 0)
- ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
- : autovacuum_multixact_freeze_max_age;
+ ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age_adjusted())
+ : autovacuum_multixact_freeze_max_age_adjusted();
av_enabled = (relopts ? relopts->enabled : true);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..c4afbc2 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern MultiXactOffset ReadMultiXactMemberCount(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..71931ef 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int autovacuum_multixact_freeze_max_age_adjusted(void);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-04-29 11:41 ` Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Amit Kapila @ 2015-04-29 11:41 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Wed, Apr 29, 2015 at 5:44 AM, Thomas Munro <thomas.munro@enterprisedb.com>
wrote:
>
> On Tue, Apr 28, 2015 at 6:30 PM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
> > Tomorrow I will send a separate patch for the autovacuum changes that
> > I sent earlier. Let's discuss and hopefully eventually commit that
> > separately.
>
> Here is a separate patch which makes autovacuum start a wrap-around
> vacuum sooner if the member space is running out, by adjusting
> autovacuum_multixact_freeze_max_age using a progressive scaling
> factor. This version includes a clearer implementation of
> autovacuum_multixact_freeze_max_age_adjusted provided by Kevin
> Grittner off-list.
>
Some comments:
1. It seems that you are using
autovacuum_multixact_freeze_max_age_adjusted()
only at couple of places, like it is not used in below calc:
vacuum_set_xid_limits()
{
..
mxid_freezemin = Min(mxid_freezemin,
autovacuum_multixact_freeze_max_age / 2);
..
}
What is the reason of using this calculation at some places and
not at other places?
2.
@@ -2684,8 +2719,8 @@ relation_needs_vacanalyze(Oid relid,
: autovacuum_freeze_max_age;
multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age
>= 0)
- ? Min(relopts->multixact_freeze_max_age,
autovacuum_multixact_freeze_max_age)
- : autovacuum_multixact_freeze_max_age;
+ ? Min(relopts->multixact_freeze_max_age,
autovacuum_multixact_freeze_max_age_adjusted())
+ : autovacuum_multixact_freeze_max_age_adjusted();
It seems that it will try to read from offset file for each
relation which might or might not be good, shall we try to
cache the oldestMultiXactMemberOffset?
3. currently there is some minimum limit of autovacuum_multixact_freeze_age
(10000000)
which might not be honored by this calculation, so not sure if that can
impact the
system performance in some cases where it is currently working sane.
4. Can you please share results that can show improvement
with current patch versus un-patched master?
5.
+ /*
+ * TODO: In future, could oldestMultiXactMemberOffset be stored in shmem,
+ *
pg_controdata, alongside oldestMultiXactId?
+ */
You might want to write the comment as:
XXX: We can store oldestMultiXactMemberOffset in shmem, pg_controldata
alongside oldestMultiXactId?
6.
+ * Returns vacuum_multixact_freeze_max_age, adjusted down to prevent
excessive use
+ * of addressable
multixact member space if required.
I think here you mean autovacuum_multixact_freeze_max_age?
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
@ 2015-04-30 05:17 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 20:36 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 3 replies; 113+ messages in thread
From: Thomas Munro @ 2015-04-30 05:17 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Wed, Apr 29, 2015 at 11:41 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> 1. It seems that you are using
> autovacuum_multixact_freeze_max_age_adjusted()
> only at couple of places, like it is not used in below calc:
>
> vacuum_set_xid_limits()
> {
> ..
> mxid_freezemin = Min(mxid_freezemin,
> autovacuum_multixact_freeze_max_age / 2);
> ..
> }
>
> What is the reason of using this calculation at some places and
> not at other places?
You're right, I will review the other places where that variable is
used and come back on this point.
> 2.
> @@ -2684,8 +2719,8 @@ relation_needs_vacanalyze(Oid relid,
> : autovacuum_freeze_max_age;
>
> multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age
>>= 0)
> - ? Min(relopts->multixact_freeze_max_age,
> autovacuum_multixact_freeze_max_age)
> - : autovacuum_multixact_freeze_max_age;
> + ? Min(relopts->multixact_freeze_max_age,
> autovacuum_multixact_freeze_max_age_adjusted())
> + : autovacuum_multixact_freeze_max_age_adjusted();
>
>
> It seems that it will try to read from offset file for each
> relation which might or might not be good, shall we try to
> cache the oldestMultiXactMemberOffset?
True. I will look into this.
> 3. currently there is some minimum limit of autovacuum_multixact_freeze_age
> (10000000)
> which might not be honored by this calculation, so not sure if that can
> impact the
> system performance in some cases where it is currently working sane.
The reason why we need to be able to set the effective freeze age
below that minimum in cases of high member data consumption rates is
that you could hit the new member space wraparound prevention error
before you consume anywhere near that many multixact IDs. That
minimum may well be entirely reasonable if the only thing you're
worried about is multixact ID wraparound prevention.
For example, my test program eats an average of 250 members per
multixact ID when run with 500 sessions (each loop creates 500
multixact IDs having 1, 2, 3, ..., 500 members). At that rate, you'll
run out of addressable member space after 2^32 / 250 = 17,179,869
multixact IDs. To prevent an error condition using only the existing
multixact ID wraparound prevention machinery, we need to have an
effective max table age (so that autovacuum wakes up and scans all
tables) and min freeze age (so that it actually freezes the tuples)
below that number. So we have to ignore the GUC minimum in this
situation.
> 4. Can you please share results that can show improvement
> with current patch versus un-patched master?
Here is my test procedure: initdb, default settings except
max_connections = 600 and shared_buffers = 1280MB, "CREATE TABLE foo
AS SELECT 42 AS id;", start monitor.sh (attached) and then run
explode_mxact_members.c (attached to my first message in this thread)
with arguments 500 100000.
Here are the edited highlights of the result for the patched server
(the complete results are attached):
time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset
10:37:01 1 0 16 1 1 0
10:38:01 656 .0079 168368 1 1 0
10:39:01 1426 .0173 366112 1 190619 47845119
10:40:01 2201 .0268 565080 1 384730 96566980
10:41:01 2979 .0363 764760 1 578342 145163592
...
11:58:57 60455 .7368 15529256 1 12601248 3162912998
11:59:59 61184 .7457 15717760 1 12601248 3162912998
12:01:01 61918 .7547 15906288 1 12794860 3211509610
12:02:03 2178 .0265 559360 12610230 12988472 3260106222 <-- oldest_mxid moved
12:03:03 2936 .0357 753936 12610230 13182583 3308828083
12:04:03 3702 .0451 950704 12610230 13376694 3357549944
...
13:18:23 58236 .7098 14956680 12610230 24623156 1885444610
13:19:23 58965 .7187 15143520 12610230 24817267 1934166471
13:20:24 59690 .7275 15329864 12610230 25011378 1982888332
13:21:24 59709 .7278 15334664 12758932 25204990 2031484944 <-- oldest_mxid moved
13:22:25 60447 .7367 15524464 12758932 25204990 2031484944
13:23:25 60836 .7415 15624192 12833782 25399101 2080206805 <-- oldest_mxid moved
13:24:26 25068 .3055 6438312 20447005 25592713 2128803417
13:25:26 25826 .3147 6632888 20447005 25786824 2177525278
13:26:26 26583 .3240 6827456 20447005 25980935 2226247139
...
14:10:42 59115 .7205 15182368 20447005 32767834 3929758788
14:11:42 59836 .7293 15367912 20447005 32767834 3929758788
14:12:43 60571 .7383 15556680 20447005 32961446 3978355400
14:13:43 38557 .4699 9902472 25189521 33155557 4027077261 <-- oldest_mxid moved
14:14:44 39267 .4786 10084408 25189521 33349169 4075673873
14:15:44 39975 .4872 10266816 25189521 33349169 4075673873
...
14:43:56 59805 .7289 15359072 25189521 37615619 851585527
14:44:56 60492 .7373 15536024 25189521 37615619 851585527
14:45:57 60468 .7370 15529536 25342215 37809231 900182139
14:46:58 48309 .5888 12406904 28023821 38003342 948904000 <-- oldest_mxid moved
14:47:58 49010 .5973 12586784 28023821 38196954 997500612
14:48:58 49716 .6059 12768152 28023821 38391065 1046222473
...
15:02:04 58882 .7177 15122600 28023821 40136068 1484218226
15:03:04 59588 .7263 15303856 28023821 40330179 1532940087
15:04:05 60293 .7349 15484592 28023821 40523791 1581536699
15:05:06 24657 .3005 6332800 35601635 40717902 1630258560 <-- oldest_mxid moved
15:06:06 25397 .3095 6522664 35601635 40717902 1630258560
15:07:06 26140 .3186 6713296 35601635 40912013 1678980421
...
15:52:22 58685 .7153 15071912 35601635 47698912 3382492070
15:53:23 59403 .7240 15255936 35601635 47892524 3431088682
15:54:23 60118 .7327 15439648 35601635 48086635 3479810543 <-- oldest_mxid moved
15:55:24 50415 .6145 12947712 37776297 48280247 3528407155
15:56:24 51144 .6234 13135568 37776297 48280247 3528407155
15:57:25 51869 .6322 13321872 37776297 48474358 3577129016
...
Observations:
1. Sometimes the values don't change from minute to minute,
presumably because there hasn't been a checkpoint to update
pg_controldata on disk, but hopefully we can still see what's going on
here despite the slight lag in the data.
2. We get to somewhere in the 73-75% SLRU used range before
wraparound vacuums are triggered. We probably need to spread things
out more that that.
3. When the autovacuum runs, it advances oldest_mxid by different
amounts each time; that's because I'm using the adjusted freeze max
age (the max age of a table before it gets a wraparound vacuum) as our
freeze min age (the max age for individual tuples before they're
frozen) here:
@@ -1931,7 +1964,9 @@ do_autovacuum(void)
{
default_freeze_min_age = vacuum_freeze_min_age;
default_freeze_table_age = vacuum_freeze_table_age;
- default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
+ default_multixact_freeze_min_age =
+ Min(vacuum_multixact_freeze_min_age,
+ autovacuum_multixact_freeze_max_age_adjusted());
default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
}
Without that change, autovacuum would trigger repeatedly as we got
near 75% SLRU usage but not freeze anything, because
default_multixact_freeze_min_age was higher than the age of any tuples
(which had only made it to an age of around ~12 million; actually it's
not exactly the tuple age per se... I don't fully understand the
treatment of locker and updater multixact IDs in the vacuum code,
HeapTupleSatisfiesVacuum and heap_freeze_tuple etc yet so I'm not sure
exactly how that value translates into vacuum work, but I can see
experimentally that a low multixact freeze min age is needed to get
relminxmid moved forward).
It's good that freeze table age ramps down so that the autovacuum
launcher trigger point jumps around a bit and we spread the autovacuum
launches over time, but it's not great that we finish up truncating
different amounts of multixacts and associated SLRU each time. We
could instead use a freeze min age of 0 to force freezing of *all*
tuples if this is a member-space-wraparound-prevention vacuum (that
is, if autovacuum_multixact_freeze_max_age !=
autovacuum_multixact_freeze_max_age_adjusted()). IIUC that'd be like
running VACUUM FREEZE and would space out our wraparound vacuums as
far apart as possible since it would trims SLRU space as much possible
when a wraparound vacuum runs, but it would presumably generate more
writes. Maybe it doesn't matter that we drop different amounts of
multixact history each time, as long as the long term behaviour works.
Thoughts?
There is less to say about the results with an unpatched server: it
drives in a straight line for a while, and then crashes into a wall
(ie the new error preventing member wraparound), which I see you have
also reproduced. It's used up all of the circular member space, but
only has around 17 million multixacts so autovacuum can't help you
(it's not even possible to set autovacuum_multixact_freeze_max_age
below 100 million), so to get things moving again you need to manually
VACUUM FREEZE all databases including template databases.
> 5.
> + /*
> + * TODO: In future, could oldestMultiXactMemberOffset be stored in shmem,
> + *
> pg_controdata, alongside oldestMultiXactId?
> + */
>
> You might want to write the comment as:
> XXX: We can store oldestMultiXactMemberOffset in shmem, pg_controldata
> alongside oldestMultiXactId?
Thanks, done.
> 6.
> + * Returns vacuum_multixact_freeze_max_age, adjusted down to prevent
> excessive use
> + * of addressable
> multixact member space if required.
>
> I think here you mean autovacuum_multixact_freeze_max_age?
Thanks, done.
FWIW, in some future release, I think we should consider getting a
bigger multixact member address space that wraps around at 2^48 or
2^64 instead of 2^32, so that we can sidestep the whole business and
go back to having just xid and mxid wraparounds to worry about.
pg_multixact/offsets would be 50% or 100% bigger (an extra byte or two
per multixact), but it's not very big. pg_multiact/members would be
no bigger for any workload that currently works without hitting the
wraparound error, but could grow bigger if needed.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
monitor-results.txt (text/plain, 18.1K) download
time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset
10:37:01 1 0 16 1 1 0
10:38:01 656 .0079 168368 1 1 0
10:39:01 1426 .0173 366112 1 190619 47845119
10:40:01 2201 .0268 565080 1 384730 96566980
10:41:01 2979 .0363 764760 1 578342 145163592
10:42:01 3756 .0457 964632 1 772453 193885453
10:43:02 4527 .0551 1162336 1 772453 193885453
10:44:02 5297 .0645 1360136 1 966564 242607314
10:45:02 6065 .0739 1557352 1 1160176 291203926
10:46:02 6831 .0832 1754352 1 1354287 339925787
10:47:02 7608 .0927 1953648 1 1547899 388522399
10:48:02 8386 .1022 2153616 1 1742010 437244260
10:49:02 9165 .1117 2353648 1 1742010 437244260
10:50:02 9943 .1211 2553704 1 1936121 485966121
10:51:02 10718 .1306 2752544 1 2129733 534562733
10:52:02 11495 .1401 2952072 1 2323844 583284594
10:53:02 12270 .1495 3151144 1 2517456 631881206
10:54:02 13046 .1590 3350296 1 2711567 680603067
10:55:03 13821 .1684 3549280 1 2711567 680603067
10:56:03 14594 .1778 3747824 1 2905678 729324928
10:57:03 15367 .1873 3946208 1 3099290 777921540
10:58:03 16137 .1966 4144552 1 3293401 826643401
10:59:03 16907 .2060 4341872 1 3487013 875240013
11:00:03 17674 .2154 4539152 1 3681124 923961874
11:01:03 18442 .2247 4736336 1 3681124 923961874
11:02:04 19209 .2341 4933536 1 3875235 972683735
11:03:04 19975 .2434 5130120 1 4068847 1021280347
11:04:04 20738 .2527 5325648 1 4262958 1070002208
11:05:04 21471 .2617 5514176 1 4456570 1118598820
11:06:04 22216 .2707 5705328 1 4456570 1118598820
11:07:05 22963 .2799 5897224 1 4650681 1167320681
11:08:05 23708 .2889 6088664 1 4844792 1216042542
11:09:05 24453 .2980 6280344 1 5038404 1264639154
11:10:05 25200 .3071 6472048 1 5232515 1313361015
11:11:05 25941 .3161 6662376 1 5232515 1313361015
11:12:06 26688 .3253 6853904 1 5426127 1361957627
11:13:06 27382 .3337 7032792 1 5620238 1410679488
11:14:06 28119 .3427 7222256 1 5814349 1459401349
11:15:07 28857 .3517 7411936 1 6007961 1507997961
11:16:07 29582 .3605 7598272 1 6007961 1507997961
11:17:08 30303 .3693 7784440 1 6202072 1556719822
11:18:09 31047 .3784 7975616 1 6395684 1605316434
11:19:10 31784 .3874 8163712 1 6589795 1654038295
11:20:10 32540 .3966 8358496 1 6783906 1702760156
11:21:11 33298 .4058 8553712 1 6783906 1702760156
11:22:12 34047 .4150 8747152 1 6977518 1751356768
11:23:13 34800 .4241 8939536 1 7171629 1800078629
11:24:14 35549 .4333 9131936 1 7365241 1848675241
11:25:15 36298 .4424 9323184 1 7559352 1897397102
11:26:16 37035 .4514 9513576 1 7559352 1897397102
11:27:17 37788 .4606 9706936 1 7753463 1946118963
11:28:18 38525 .4695 9896352 1 7947075 1994715575
11:29:19 39223 .4780 10076816 1 8141167 2043428107
11:30:20 39939 .4868 10259448 1 8141167 2043428107
11:31:22 40686 .4959 10449312 1 8334798 2092034048
11:32:22 41377 .5043 10629176 1 8528909 2140755909
11:33:23 42109 .5132 10817896 1 8723020 2189477770
11:34:25 42844 .5222 11005848 1 8916632 2238074382
11:35:26 43576 .5311 11193824 1 8916632 2238074382
11:36:27 44308 .5400 11382536 1 9110743 2286796243
11:37:29 45042 .5490 11569888 1 9304355 2335392855
11:38:30 45760 .5577 11752936 1 9498466 2384114716
11:39:30 46502 .5668 11945272 1 9692577 2432836577
11:40:31 47227 .5756 12132216 1 9692577 2432836577
11:41:33 47977 .5848 12324488 1 9886189 2481433189
11:42:34 48720 .5938 12514808 1 10080300 2530155050
11:43:36 49433 .6025 12698544 1 10273912 2578751662
11:44:37 50173 .6115 12888376 1 10273912 2578751662
11:45:38 50909 .6205 13077000 1 10468023 2627473523
11:46:40 51648 .6295 13267464 1 10662134 2676195384
11:47:41 52380 .6384 13455768 1 10855746 2724791996
11:48:42 53117 .6474 13644264 1 11049857 2773513857
11:49:44 53849 .6563 13833232 1 11049857 2773513857
11:50:45 54593 .6654 14021168 1 11243469 2822110469
11:51:46 55316 .6742 14209360 1 11437580 2870832330
11:52:47 56055 .6832 14399296 1 11631691 2919554191
11:53:49 56794 .6922 14590264 1 11825303 2968150803
11:54:50 57532 .7012 14779080 1 11825303 2968150803
11:55:52 58268 .7102 14967552 1 12019414 3016872664
11:56:54 58998 .7191 15156784 1 12213026 3065469276
11:57:56 59729 .7280 15343568 1 12407137 3114191137
11:58:57 60455 .7368 15529256 1 12601248 3162912998
11:59:59 61184 .7457 15717760 1 12601248 3162912998
12:01:01 61918 .7547 15906288 1 12794860 3211509610
12:02:03 2178 .0265 559360 12610230 12988472 3260106222
12:03:03 2936 .0357 753936 12610230 13182583 3308828083
12:04:03 3702 .0451 950704 12610230 13376694 3357549944
12:05:03 4472 .0545 1148360 12610230 13376694 3357549944
12:06:03 5243 .0639 1346568 12610230 13570306 3406146556
12:07:03 6010 .0732 1543416 12610230 13764417 3454868417
12:08:03 6775 .0825 1739944 12610230 13958029 3503465029
12:09:03 7539 .0918 1936240 12610230 14152140 3552186890
12:10:03 8305 .1012 2132656 12610230 14152140 3552186890
12:11:03 9067 .1105 2328640 12610230 14346251 3600908751
12:12:04 9826 .1197 2523496 12610230 14539863 3649505363
12:13:04 10585 .1290 2718312 12610230 14733974 3698227224
12:14:04 11341 .1382 2912456 12610230 14927586 3746823836
12:15:04 12097 .1474 3106504 12610230 15121697 3795545697
12:16:04 12853 .1566 3301064 12610230 15121697 3795545697
12:17:04 13604 .1658 3494176 12610230 15315808 3844267558
12:18:04 14345 .1748 3684160 12610230 15509420 3892864170
12:19:04 15076 .1837 3871952 12610230 15703531 3941586031
12:20:05 15808 .1926 4060080 12610230 15897143 3990182643
12:21:05 16539 .2015 4247656 12610230 15897143 3990182643
12:22:05 17286 .2107 4439416 12610230 16091254 4038904504
12:23:05 18032 .2197 4631280 12610230 16285365 4087626365
12:24:05 18779 .2289 4822616 12610230 16478977 4136222977
12:25:05 19506 .2377 5009968 12610230 16673088 4184944838
12:26:06 20232 .2466 5196104 12610230 16673088 4184944838
12:27:06 20961 .2554 5383040 12610230 16866700 4233541450
12:28:06 21686 .2643 5569168 12610230 17060811 4282263311
12:29:06 22409 .2731 5755024 12610230 17254922 36017876
12:30:06 23131 .2819 5940744 12610230 17254922 36017876
12:31:07 23854 .2907 6126328 12610230 17448534 84614488
12:32:07 24579 .2995 6312336 12610230 17642645 133336349
12:33:07 25301 .3083 6497864 12610230 17836257 181932961
12:34:07 26022 .3171 6682944 12610230 18030368 230654822
12:35:07 26740 .3259 6867312 12610230 18030368 230654822
12:36:08 27458 .3346 7051744 12610230 18224479 279376683
12:37:08 28177 .3434 7236320 12610230 18418091 327973295
12:38:08 28893 .3521 7420288 12610230 18612202 376695156
12:39:08 29611 .3609 7604744 12610230 18612202 376695156
12:40:09 30330 .3696 7789136 12610230 18805814 425291768
12:41:09 31046 .3784 7973264 12610230 18999925 474013629
12:42:09 31761 .3871 8156808 12610230 19194036 522735490
12:43:09 32476 .3958 8340456 12610230 19194036 522735490
12:44:10 33191 .4045 8524008 12610230 19387648 571332102
12:45:10 33907 .4132 8708144 12610230 19581759 620053963
12:46:11 34622 .4220 8891808 12610230 19775371 668650575
12:47:11 35371 .4311 9084120 12610230 19969482 717372436
12:48:11 36120 .4402 9276512 12610230 19969482 717372436
12:49:11 36869 .4494 9468752 12610230 20163593 766094297
12:50:12 37618 .4585 9661072 12610230 20357205 814690909
12:51:12 38362 .4676 9852136 12610230 20551316 863412770
12:52:12 39103 .4766 10042600 12610230 20744928 912009382
12:53:13 39848 .4857 10233864 12610230 20744928 912009382
12:54:13 40593 .4947 10425208 12610230 20939039 960731243
12:55:13 41338 .5038 10616480 12610230 21133150 1009453104
12:56:14 42080 .5129 10807008 12610230 21326762 1058049716
12:57:14 42819 .5219 10996904 12610230 21520873 1106771577
12:58:14 43560 .5309 11187104 12610230 21520873 1106771577
12:59:15 44300 .5399 11377128 12610230 21714485 1155368189
13:00:15 45038 .5489 11566808 12610230 21908596 1204090050
13:01:16 45776 .5579 11756216 12610230 22102707 1252811911
13:02:16 46510 .5669 11944856 12610230 22296319 1301408523
13:03:16 47250 .5759 12134816 12610230 22296319 1301408523
13:04:17 47987 .5849 12324328 12610230 22490430 1350130384
13:05:17 48724 .5939 12513576 12610230 22684042 1398726996
13:06:18 49459 .6028 12702376 12610230 22878153 1447448857
13:07:18 50192 .6117 12890448 12610230 23072264 1496170718
13:08:18 50927 .6207 13079112 12610230 23072264 1496170718
13:09:19 51660 .6296 13267672 12610230 23265876 1544767330
13:10:19 52391 .6386 13455336 12610230 23459987 1593489191
13:11:20 53123 .6475 13643080 12610230 23653599 1642085803
13:12:20 53855 .6564 13831192 12610230 23653599 1642085803
13:13:20 54587 .6653 14019240 12610230 23847710 1690807664
13:14:21 55320 .6743 14207720 12610230 24041821 1739529525
13:15:22 56049 .6831 14394512 12610230 24235433 1788126137
13:16:22 56777 .6920 14581720 12610230 24429544 1836847998
13:17:22 57507 .7009 14769296 12610230 24429544 1836847998
13:18:23 58236 .7098 14956680 12610230 24623156 1885444610
13:19:23 58965 .7187 15143520 12610230 24817267 1934166471
13:20:24 59690 .7275 15329864 12610230 25011378 1982888332
13:21:24 59709 .7278 15334664 12758932 25204990 2031484944
13:22:25 60447 .7367 15524464 12758932 25204990 2031484944
13:23:25 60836 .7415 15624192 12833782 25399101 2080206805
13:24:26 25068 .3055 6438312 20447005 25592713 2128803417
13:25:26 25826 .3147 6632888 20447005 25786824 2177525278
13:26:26 26583 .3240 6827456 20447005 25980935 2226247139
13:27:26 27339 .3332 7021624 20447005 25980935 2226247139
13:28:27 28095 .3424 7215856 20447005 26174547 2274843751
13:29:27 28851 .3516 7410016 20447005 26368658 2323565612
13:30:27 29604 .3608 7603520 20447005 26562270 2372162224
13:31:28 30356 .3700 7796480 20447005 26756381 2420884085
13:32:28 31109 .3791 7989880 20447005 26756381 2420884085
13:33:28 31862 .3883 8183064 20447005 26950492 2469605946
13:34:28 32614 .3975 8376456 20447005 27144104 2518202558
13:35:29 33364 .4066 8568864 20447005 27338215 2566924419
13:36:29 34112 .4157 8761112 20447005 27531827 2615521031
13:37:29 34863 .4249 8953736 20447005 27531827 2615521031
13:38:30 35612 .4340 9146208 20447005 27725938 2664242892
13:39:30 36358 .4431 9338040 20447005 27920049 2712964753
13:40:30 37102 .4522 9528872 20447005 28113661 2761561365
13:41:30 37843 .4612 9719232 20447005 28307772 2810283226
13:42:31 38586 .4703 9910056 20447005 28307772 2810283226
13:43:31 39329 .4793 10100856 20447005 28501384 2858879838
13:44:32 40072 .4884 10291704 20447005 28695495 2907601699
13:45:32 40811 .4974 10481512 20447005 28889606 2956323560
13:46:32 41550 .5064 10671320 20447005 29083218 3004920172
13:47:32 42289 .5154 10861168 20447005 29083218 3004920172
13:48:33 43031 .5245 11051640 20447005 29277329 3053642033
13:49:33 43772 .5335 11241968 20447005 29470941 3102238645
13:50:34 44509 .5425 11431352 20447005 29665052 3150960506
13:51:34 45244 .5514 11619984 20447005 29859163 3199682367
13:52:34 45978 .5604 11808600 20447005 29859163 3199682367
13:53:35 46713 .5693 11997224 20447005 30052775 3248278979
13:54:35 47450 .5783 12186496 20447005 30246886 3297000840
13:55:36 48183 .5873 12374928 20447005 30440498 3345597452
13:56:36 48915 .5962 12563104 20447005 30634609 3394319313
13:57:36 49644 .6051 12750496 20447005 30634609 3394319313
13:58:37 50380 .6140 12939384 20447005 30828720 3443041174
13:59:37 51115 .6230 13127632 20447005 31022332 3491637786
14:00:38 51845 .6319 13314816 20447005 31216443 3540359647
14:01:38 52570 .6407 13501384 20447005 31410055 3588956259
14:02:38 53299 .6496 13689320 20447005 31410055 3588956259
14:03:39 54028 .6585 13876200 20447005 31604166 3637678120
14:04:39 54759 .6674 14063504 20447005 31798277 3686399981
14:05:40 55485 .6763 14249768 20447005 31991889 3734996593
14:06:40 56211 .6851 14437064 20447005 31991889 3734996593
14:07:40 56940 .6940 14624464 20447005 32186000 3783718454
14:08:41 57667 .7029 14810632 20447005 32379612 3832315066
14:09:42 58393 .7117 14996808 20447005 32573723 3881036927
14:10:42 59115 .7205 15182368 20447005 32767834 3929758788
14:11:42 59836 .7293 15367912 20447005 32767834 3929758788
14:12:43 60571 .7383 15556680 20447005 32961446 3978355400
14:13:43 38557 .4699 9902472 25189521 33155557 4027077261
14:14:44 39267 .4786 10084408 25189521 33349169 4075673873
14:15:44 39975 .4872 10266816 25189521 33349169 4075673873
14:16:44 40684 .4959 10449064 25189521 33543280 4124395734
14:17:45 41394 .5045 10631160 25189521 33737391 4173117595
14:18:45 42102 .5131 10812632 25189521 33931003 4221714207
14:19:45 42808 .5217 10994368 25189521 33931003 4221714207
14:20:46 43517 .5304 11176184 25189521 34125114 4270436068
14:21:46 44223 .5390 11357224 25189521 34318726 24065384
14:22:47 44925 .5475 11537456 25189521 34512837 72787245
14:23:47 45625 .5561 11718064 25189521 34512837 72787245
14:24:47 46327 .5646 11898088 25189521 34706948 121509106
14:25:48 47028 .5732 12078104 25189521 34900560 170105718
14:26:48 47728 .5817 12257512 25189521 35094671 218827579
14:27:49 48424 .5902 12436264 25189521 35288283 267424191
14:28:49 49122 .5987 12615712 25189521 35288283 267424191
14:29:49 49821 .6072 12795120 25189521 35482394 316146052
14:30:50 50517 .6157 12973552 25189521 35676505 364867913
14:31:50 51211 .6242 13152160 25189521 35870117 413464525
14:32:51 51910 .6327 13331520 25189521 35870117 413464525
14:33:51 52618 .6413 13513720 25189521 36064228 462186386
14:34:52 53348 .6502 13700768 25189521 36257840 510782998
14:35:52 54077 .6591 13888168 25189521 36451951 559504859
14:36:52 54804 .6680 14074960 25189521 36451951 559504859
14:37:53 55534 .6769 14262392 25189521 36646062 608226720
14:38:53 56261 .6857 14449024 25189521 36839674 656823332
14:39:54 56986 .6946 14635296 25189521 37033785 705545193
14:40:54 57713 .7034 14822264 25189521 37227397 754141805
14:41:55 58431 .7122 15006400 25189521 37227397 754141805
14:42:55 59122 .7206 15183816 25189521 37421508 802863666
14:43:56 59805 .7289 15359072 25189521 37615619 851585527
14:44:56 60492 .7373 15536024 25189521 37615619 851585527
14:45:57 60468 .7370 15529536 25342215 37809231 900182139
14:46:58 48309 .5888 12406904 28023821 38003342 948904000
14:47:58 49010 .5973 12586784 28023821 38196954 997500612
14:48:58 49716 .6059 12768152 28023821 38391065 1046222473
14:49:59 50424 .6146 12950128 28023821 38391065 1046222473
14:50:59 51134 .6232 13132424 28023821 38584677 1094819085
14:52:00 51836 .6318 13312536 28023821 38778788 1143540946
14:53:00 52539 .6404 13493096 28023821 38972899 1192262807
14:54:00 53245 .6490 13674848 28023821 38972899 1192262807
14:55:01 53952 .6576 13856200 28023821 39166511 1240859419
14:56:01 54657 .6662 14037120 28023821 39360622 1289581280
14:57:02 55360 .6747 14217688 28023821 39554234 1338177892
14:58:02 56068 .6834 14399464 28023821 39554234 1338177892
14:59:03 56773 .6920 14580688 28023821 39748345 1386899753
15:00:03 57477 .7005 14761440 28023821 39942456 1435621614
15:01:03 58179 .7091 14941792 28023821 40136068 1484218226
15:02:04 58882 .7177 15122600 28023821 40136068 1484218226
15:03:04 59588 .7263 15303856 28023821 40330179 1532940087
15:04:05 60293 .7349 15484592 28023821 40523791 1581536699
15:05:06 24657 .3005 6332800 35601635 40717902 1630258560
15:06:06 25397 .3095 6522664 35601635 40717902 1630258560
15:07:06 26140 .3186 6713296 35601635 40912013 1678980421
15:08:06 26874 .3275 6901816 35601635 41105625 1727577033
15:09:07 27607 .3365 7090192 35601635 41299736 1776298894
15:10:07 28330 .3453 7275936 35601635 41493348 1824895506
15:11:07 29062 .3542 7463952 35601635 41493348 1824895506
15:12:07 29808 .3633 7655592 35601635 41687459 1873617367
15:13:08 30551 .3723 7846128 35601635 41881570 1922339228
15:14:08 31294 .3814 8036976 35601635 42075182 1970935840
15:15:08 32019 .3902 8223264 35601635 42269293 2019657701
15:16:08 32753 .3992 8411584 35601635 42269293 2019657701
15:17:09 33485 .4081 8599808 35601635 42462905 2068254313
15:18:09 34211 .4170 8786216 35601635 42657016 2116976174
15:19:09 34940 .4258 8973568 35601635 42851127 2165698035
15:20:09 35664 .4347 9159264 35601635 42851127 2165698035
15:21:10 36387 .4435 9345280 35601635 43044739 2214294647
15:22:10 37118 .4524 9532840 35601635 43238850 2263016508
15:23:11 37818 .4609 9712704 35601635 43432462 2311613120
15:24:11 38535 .4697 9896648 35601635 43626573 2360334981
15:25:11 39258 .4785 10082576 35601635 43626573 2360334981
15:26:12 39985 .4873 10269368 35601635 43820684 2409056842
15:27:12 40710 .4962 10455368 35601635 44014296 2457653454
15:28:12 41441 .5051 10643016 35601635 44208407 2506375315
15:29:13 42170 .5140 10830448 35601635 44208407 2506375315
15:30:13 42870 .5225 11009912 35601635 44402019 2554971927
15:31:13 43576 .5311 11191392 35601635 44596130 2603693788
15:32:14 44304 .5400 11378376 35601635 44790241 2652415649
15:33:14 45034 .5489 11565808 35601635 44983853 2701012261
15:34:14 45767 .5578 11754088 35601635 44983853 2701012261
15:35:15 46492 .5666 11940560 35601635 45177964 2749734122
15:36:15 47198 .5753 12121616 35601635 45371576 2798330734
15:37:16 47905 .5839 12303152 35601635 45565687 2847052595
15:38:16 48625 .5926 12488000 35601635 45565687 2847052595
15:39:16 49345 .6014 12673096 35601635 45759798 2895774456
15:40:17 50070 .6103 12859232 35601635 45953410 2944371068
15:41:17 50791 .6191 13044352 35601635 46147521 2993092929
15:42:18 51515 .6279 13230304 35601635 46341133 3041689541
15:43:18 52240 .6367 13416384 35601635 46341133 3041689541
15:44:18 52963 .6455 13602280 35601635 46535244 3090411402
15:45:19 53682 .6543 13786872 35601635 46729355 3139133263
15:46:19 54403 .6631 13972056 35601635 46922967 3187729875
15:47:20 55123 .6719 14157216 35601635 46922967 3187729875
15:48:20 55844 .6806 14342216 35601635 47117078 3236451736
15:49:21 56565 .6894 14527240 35601635 47310690 3285048348
15:50:21 57266 .6980 14707264 35601635 47504801 3333770209
15:51:21 57975 .7066 14889744 35601635 47504801 3333770209
15:52:22 58685 .7153 15071912 35601635 47698912 3382492070
15:53:23 59403 .7240 15255936 35601635 47892524 3431088682
15:54:23 60118 .7327 15439648 35601635 48086635 3479810543
15:55:24 50415 .6145 12947712 37776297 48280247 3528407155
15:56:24 51144 .6234 13135568 37776297 48280247 3528407155
15:57:25 51869 .6322 13321872 37776297 48474358 3577129016
15:58:25 52585 .6409 13504976 37776297 48668469 3625850877
15:59:25 53304 .6497 13689912 37776297 48862081 3674447489
16:00:26 54025 .6585 13875096 37776297 48862081 3674447489
16:01:26 54743 .6672 14059792 37776297 49056192 3723169350
16:02:27 55458 .6759 14242880 37776297 49249804 3771765962
16:03:27 56173 .6847 14426592 37776297 49443915 3820487823
16:04:28 56887 .6934 14609752 37776297 49638026 3869209684
16:05:28 57601 .7021 14793568 37776297 49638026 3869209684
16:06:29 58128 .7085 14927960 37776297 49831638 3917806296
16:07:29 58128 .7085 14927960 37776297 49831638 3917806296
16:08:29 58128 .7085 14927960 37776297 49831638 3917806296
^C
monitor.sh (application/x-sh, 846B) download
memberswrap-autovacuum-2.patch (application/octet-stream, 5.9K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index c8faa17..c3aa3e1 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2574,6 +2574,29 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of members in the
+ * members SLRU area.
+ */
+MultiXactOffset
+ReadMultiXactMemberCount(void)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ return nextOffset - oldestOffset;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..3502a7f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -601,7 +601,7 @@ vacuum_set_xid_limits(Relation rel,
if (freezetable < 0)
freezetable = vacuum_multixact_freeze_table_age;
freezetable = Min(freezetable,
- autovacuum_multixact_freeze_max_age * 0.95);
+ autovacuum_multixact_freeze_max_age_adjusted() * 0.95);
Assert(freezetable >= 0);
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..90f3766 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1052,6 +1052,39 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Returns autovacuum_multixact_freeze_max_age, adjusted down to prevent
+ * excessive use of addressable multixact member space if required.
+ *
+ * The goal is to avoid the situation where new multixacts can't be created
+ * because the offsets used to address pg_multixact/members would wrap around.
+ *
+ * If less than "minimum safe member count" of the total available member
+ * space is used, then we make no adjustment (this should apply to most
+ * typical users). If more than the "max safe member count" of the total
+ * available member space is used, then we use a freeze max age of zero to
+ * trigger aggressive vacuuming. In between, we scale the given freeze max
+ * age down linearly, so that vacuuming becomes more aggressive as the member
+ * SLRU grows.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we just define constants at 25% and 75%.
+ */
+#define MIN_SAFE_MEMBER_COUNT (MaxMultiXactOffset / 4)
+#define MAX_SAFE_MEMBER_COUNT (MaxMultiXactOffset - MIN_SAFE_MEMBER_COUNT)
+int
+autovacuum_multixact_freeze_max_age_adjusted()
+{
+ MultiXactOffset mxact_member_count = ReadMultiXactMemberCount();
+ if (mxact_member_count <= MIN_SAFE_MEMBER_COUNT)
+ return autovacuum_multixact_freeze_max_age;
+ else if (mxact_member_count >= MAX_SAFE_MEMBER_COUNT)
+ return 0;
+ else return (int) (autovacuum_multixact_freeze_max_age
+ * (((double) (MAX_SAFE_MEMBER_COUNT - mxact_member_count))
+ / ((double) (MAX_SAFE_MEMBER_COUNT - MIN_SAFE_MEMBER_COUNT))));
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1118,7 +1151,7 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age_adjusted();
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1931,7 +1964,9 @@ do_autovacuum(void)
{
default_freeze_min_age = vacuum_freeze_min_age;
default_freeze_table_age = vacuum_freeze_table_age;
- default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
+ default_multixact_freeze_min_age =
+ Min(vacuum_multixact_freeze_min_age,
+ autovacuum_multixact_freeze_max_age_adjusted());
default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
}
@@ -2684,8 +2719,8 @@ relation_needs_vacanalyze(Oid relid,
: autovacuum_freeze_max_age;
multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age >= 0)
- ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
- : autovacuum_multixact_freeze_max_age;
+ ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age_adjusted())
+ : autovacuum_multixact_freeze_max_age_adjusted();
av_enabled = (relopts ? relopts->enabled : true);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..c4afbc2 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern MultiXactOffset ReadMultiXactMemberCount(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..71931ef 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int autovacuum_multixact_freeze_max_age_adjusted(void);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-01 10:51 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-01 10:51 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Thu, Apr 30, 2015 at 5:17 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Wed, Apr 29, 2015 at 11:41 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>> 1. It seems that you are using
>> autovacuum_multixact_freeze_max_age_adjusted()
>> only at couple of places, like it is not used in below calc:
>>
>> vacuum_set_xid_limits()
>> {
>> ..
>> mxid_freezemin = Min(mxid_freezemin,
>> autovacuum_multixact_freeze_max_age / 2);
>> ..
>> }
>>
>> What is the reason of using this calculation at some places and
>> not at other places?
>
> You're right, I will review the other places where that variable is
> used and come back on this point.
Those other places are for capping the effective table and tuple
multixact freeze ages for manual vacuums, so that manual vacuums (say
in nightly cronjobs) get a chance to run a wraparound scans before
autovacuum kicks in at a less convenient time. So, yeah, I think we
want to incorporate member wraparound prevention into that logic, and
I will add that in the next version of the patch.
>> 2.
>> @@ -2684,8 +2719,8 @@ relation_needs_vacanalyze(Oid relid,
>> : autovacuum_freeze_max_age;
>>
>> multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age
>>>= 0)
>> - ? Min(relopts->multixact_freeze_max_age,
>> autovacuum_multixact_freeze_max_age)
>> - : autovacuum_multixact_freeze_max_age;
>> + ? Min(relopts->multixact_freeze_max_age,
>> autovacuum_multixact_freeze_max_age_adjusted())
>> + : autovacuum_multixact_freeze_max_age_adjusted();
>>
>>
>> It seems that it will try to read from offset file for each
>> relation which might or might not be good, shall we try to
>> cache the oldestMultiXactMemberOffset?
>
> True. I will look into this.
The version attached reuses the value by passing it as a new parameter
to the functions relation_needs_vacanalyze and table_recheck_autovac.
[...]
>> 4. Can you please share results that can show improvement
>> with current patch versus un-patched master?
> [...]
> 2. We get to somewhere in the 73-75% SLRU used range before
> wraparound vacuums are triggered. We probably need to spread things
> out more that that.
The version attached should spread the work out a lot better. Instead
of using a proportion of your autovacuum_multixact_max_freeze_age, it
uses a proportion of the number of active multixacts (see
compute_max_multixact_age_to_avoid_member_wrap).
> 3. When the autovacuum runs, it advances oldest_mxid by different
> amounts each time; that's because I'm using the adjusted freeze max
> age (the max age of a table before it gets a wraparound vacuum) as our
> freeze min age (the max age for individual tuples before they're
> frozen) here:
>
> @@ -1931,7 +1964,9 @@ do_autovacuum(void)
> {
> default_freeze_min_age = vacuum_freeze_min_age;
> default_freeze_table_age = vacuum_freeze_table_age;
> - default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
> + default_multixact_freeze_min_age =
> + Min(vacuum_multixact_freeze_min_age,
> + autovacuum_multixact_freeze_max_age_adjusted());
> default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
> }
That was just completely wrong... removed, and replaced with code
that sets multixact_freeze_min_age to zero in table_recheck_autovac in
this scenario.
I will post another version with some more test results soon, but
wanted to share this WIP patch and respond to the above questions.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-autovacuum-3.patch (application/octet-stream, 9.9K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..1d7d942 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2578,6 +2578,32 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..0592817 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int max_multixact_age_to_avoid_member_wrap);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_freeze_age_to_avoid_member_wrap,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1052,6 +1054,68 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the addressing space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return a number at
+ * least as large as autovacuum_multixact_freeze_max_age, so that no special
+ * action is taken. This should apply to most typical users who don't make
+ * use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between, we return the current number of active multixids scaled down
+ * linearly for higher usage fractions, so that vacuuming becomes more
+ * aggressive as the member SLRU grows, in the hope that different tables will
+ * be vacuumed at different times due to their varying relminmxid values.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we just define constants at 50% and 75%.
+ */
+#define SAFE_MEMBER_COUNT (MaxMultiXactOffset / 2)
+#define DANGEROUS_MEMBER_COUNT (MaxMultiXactOffset - (SAFE_MEMBER_COUNT / 2))
+int
+compute_max_multixact_age_to_avoid_member_wrap(void)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members <= SAFE_MEMBER_COUNT)
+ {
+ /*
+ * There is no danger of member wrap, so return a number that is not
+ * lower than autovacuum_multixact_freeze_max_age.
+ */
+ return autovacuum_multixact_freeze_max_age; /* XXX: MAXINT? */
+ }
+
+ if (members >= DANGEROUS_MEMBER_COUNT)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ /*
+ * Choose a cutoff age which is a fraction of the approximate current
+ * number of active multixacts. If we are using an amount of member
+ * address space near SAFE_MEMBER_COUNT, we use a number close to the
+ * number of active multixacts, so that only tables with the oldest
+ * relminmxid values become candidates for wraparound vacuums. As we get
+ * closer to DANGEROUS_MEMBER_COUNT, we use a number closer to zero, so
+ * that more tables become candidates for wraparound vacuums.
+ */
+ fraction = (double) (members - SAFE_MEMBER_COUNT) /
+ (double) (DANGEROUS_MEMBER_COUNT - SAFE_MEMBER_COUNT);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1118,7 +1182,8 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multiForceLimit = recentMulti - Min(autovacuum_multixact_freeze_max_age,
+ compute_max_multixact_age_to_avoid_member_wrap());
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1946,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int max_multixact_age_to_avoid_member_wrap;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1920,6 +1986,8 @@ do_autovacuum(void)
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
dbForm = (Form_pg_database) GETSTRUCT(tuple);
+ max_multixact_age_to_avoid_member_wrap = compute_max_multixact_age_to_avoid_member_wrap();
+
if (dbForm->datistemplate || !dbForm->datallowconn)
{
default_freeze_min_age = 0;
@@ -2001,6 +2069,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2198,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2305,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ max_multixact_age_to_avoid_member_wrap);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2513,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int max_multixact_age_to_avoid_member_wrap)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2560,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2623,16 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (max_multixact_age_to_avoid_member_wrap < multixact_freeze_table_age)
+ {
+ multixact_freeze_table_age = max_multixact_age_to_avoid_member_wrap;
+ multixact_freeze_min_age = 0;
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2624,6 +2707,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int max_multixact_age_to_avoid_member_wrap,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2771,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (max_multixact_age_to_avoid_member_wrap < multixact_freeze_max_age)
+ multixact_freeze_max_age = max_multixact_age_to_avoid_member_wrap;
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..0500435 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern void ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..7fc7bd3 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int compute_max_multixact_age_to_avoid_member_wrap(void);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-01 19:08 ` Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-01 19:08 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Fri, May 1, 2015 at 6:51 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Those other places are for capping the effective table and tuple
> multixact freeze ages for manual vacuums, so that manual vacuums (say
> in nightly cronjobs) get a chance to run a wraparound scans before
> autovacuum kicks in at a less convenient time. So, yeah, I think we
> want to incorporate member wraparound prevention into that logic, and
> I will add that in the next version of the patch.
+1. On a quick read-through of the patch, the biggest thing that
jumped out at me was that it only touches the autovacuum logic.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-02 06:16 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 18:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-02 06:16 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Sat, May 2, 2015 at 7:08 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Fri, May 1, 2015 at 6:51 AM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> Those other places are for capping the effective table and tuple
>> multixact freeze ages for manual vacuums, so that manual vacuums (say
>> in nightly cronjobs) get a chance to run a wraparound scans before
>> autovacuum kicks in at a less convenient time. So, yeah, I think we
>> want to incorporate member wraparound prevention into that logic, and
>> I will add that in the next version of the patch.
>
> +1. On a quick read-through of the patch, the biggest thing that
> jumped out at me was that it only touches the autovacuum logic.
Here's a new version which sets up the multixact parameters in
ExecVacuum for regular VACUUM commands just like it does for
autovacuum if needed. When computing
max_multixact_age_to_avoid_member_wrap for a manual vacuum, it uses
lower constants, so that any manually scheduled vacuums get a chance
to deal with some of this problem before autovacuum has to. Here are
the arbitrary constants currently used: at 50% member address space
usage, autovacuum starts wraparound scan of tables with the oldest
active multixacts, and then younger ones as the usage increases, until
at 75% usage it vacuums with multixact_freeze_table_age = 0; for
manual VACUUM those numbers are halved so that it has a good head
start.
Halving the thresholds so much lower for manual vacuums may be too
much of a head start, but if we give it only a small head start, it
seems to me that you'd finish up with slim odds of actually getting
the wraparound scans done by your scheduled vacuum job. A head start
of 25% of the usage before autovacuum starts on tables with the oldest
relminmxids creates a target big enough that you might hit it with
your vacuum cronjob. Also, as far as I can tell, manual vacuums will
only help you get the wraparound scans on your *connectable* databases
done at a time that suits you better, you'll still be dependent on
autovacuum to deal with non-connectable databases, in other words
template0. In practice I guess if you run vacuumdb -a at midnight
you'll see all the pg_database.datminmxid values advance except for
template0's, and then some time later, most likely during busy load
time producing many multixact members, member space usage will finally
hit 50%, autovacuum will very quickly process template0, the
cluster-wide oldest mxid will finally advance, and then segment files
will be deleted at the next checkpoint. Or am I missing something?
Also attached is the output of the monitor.sh script posted upthread,
while running explode_mxact_members.c. It looks better than the last
results to me: whenever usage reaches 50%, autovacuum advances things
such that usage drops right back to 0% (because it now uses
multixact_freeze_min_age = 0) , and the system will happily chug on
forever. What this test doesn't really show adequately is that if you
had a lot of different tables and databases with different relminmxid
values, they'd be vacuumed at different times. I should probably come
up with a way to demonstrate that...
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
monitor-output.txt (text/plain, 9.4K) download
time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset
13:48:36 1 0 16 1 1 0
13:49:36 369 .0044 94752 1 1 0
13:50:36 1136 .0138 291672 1 190619 47845119
13:51:36 1910 .0232 490296 1 384730 96566980
13:52:36 2680 .0326 687968 1 384730 96566980
13:53:36 3457 .0421 887656 1 578342 145163592
13:54:36 4235 .0516 1087336 1 772453 193885453
13:55:36 5012 .0610 1287024 1 966065 242482065
13:56:36 5787 .0705 1486216 1 1160176 291203926
13:57:36 6570 .0800 1687008 1 1354287 339925787
13:58:36 7352 .0896 1888056 1 1354287 339925787
13:59:37 8137 .0991 2090048 1 1547899 388522399
14:00:37 8919 .1087 2291264 1 1742010 437244260
14:01:37 9701 .1182 2492496 1 1935622 485840872
14:02:37 10487 .1278 2694104 1 2129733 534562733
14:03:38 11269 .1373 2894320 1 2323844 583284594
14:04:38 12051 .1468 3095248 1 2323844 583284594
14:05:38 12831 .1563 3296152 1 2517456 631881206
14:06:39 13614 .1659 3497680 1 2711567 680603067
14:07:39 14393 .1754 3696744 1 2905179 729199679
14:08:39 15171 .1849 3897040 1 3099290 777921540
14:09:40 15946 .1943 4096728 1 3293401 826643401
14:10:40 16726 .2038 4297120 1 3487013 875240013
14:11:41 17498 .2132 4494872 1 3487013 875240013
14:12:41 18266 .2226 4691480 1 3681124 923961874
14:13:41 19031 .2319 4888936 1 3875235 972683735
14:14:42 19802 .2413 5087488 1 4068847 1021280347
14:15:42 20575 .2507 5285624 1 4262958 1070002208
14:16:43 21342 .2601 5482608 1 4262958 1070002208
14:17:43 22103 .2694 5678224 1 4456570 1118598820
14:18:44 22862 .2786 5871440 1 4650681 1167320681
14:19:44 23617 .2878 6066728 1 4844792 1216042542
14:20:45 24375 .2971 6261816 1 5038404 1264639154
14:21:46 25135 .3063 6457320 1 5232515 1313361015
14:22:46 25893 .3156 6650232 1 5232515 1313361015
14:23:47 26643 .3247 6843872 1 5426127 1361957627
14:24:47 27403 .3340 7039200 1 5620238 1410679488
14:25:48 28161 .3432 7234760 1 5814349 1459401349
14:26:49 28920 .3525 7429000 1 6007961 1507997961
14:27:50 29674 .3617 7622848 1 6007961 1507997961
14:28:51 30429 .3709 7817488 1 6202072 1556719822
14:29:52 31186 .3801 8011176 1 6395684 1605316434
14:30:52 31939 .3893 8204704 1 6589795 1654038295
14:31:53 32690 .3984 8398248 1 6783906 1702760156
14:32:54 33445 .4076 8589552 1 6783906 1702760156
14:33:54 34190 .4167 8782880 1 6977518 1751356768
14:34:55 34942 .4259 8975856 1 7171629 1800078629
14:35:56 35698 .4351 9170800 1 7365241 1848675241
14:36:58 36451 .4443 9363688 1 7559352 1897397102
14:37:58 37201 .4534 9556872 1 7753463 1946118963
14:38:59 37954 .4626 9750784 1 7753463 1946118963
14:40:01 38705 .4717 9942880 1 7947075 1994715575
14:41:02 39449 .4808 10131632 1 8141186 2043437436
14:42:02 40186 .4898 10323568 1 8334798 2092034048
14:43:03 40937 .4989 10517368 1 8528909 2140755909
14:44:04 41703 .5083 10713400 1 8528909 2140755909
14:45:05 1374 .0167 352960 8573819 8722521 2189352521
14:46:05 2164 .0263 555904 8573819 8916632 2238074382
14:47:05 2957 .0360 759504 8573819 9110244 2286670994
14:48:05 3747 .0456 962432 8573819 9304355 2335392855
14:49:06 4538 .0553 1165576 8573819 9498466 2384114716
14:50:06 5326 .0649 1367952 8573819 9498466 2384114716
14:51:06 6116 .0745 1570712 8573819 9692078 2432711328
14:52:06 6900 .0841 1772240 8573819 9886189 2481433189
14:53:06 7685 .0936 1973904 8573819 10079801 2530029801
14:54:06 8465 .1031 2174064 8573819 10273912 2578751662
14:55:06 9246 .1127 2374888 8573819 10468023 2627473523
14:56:06 10025 .1221 2574704 8573819 10661635 2676070135
14:57:06 10805 .1317 2775152 8573819 10661635 2676070135
14:58:06 11585 .1412 2975272 8573819 10855746 2724791996
14:59:06 12364 .1507 3175552 8573819 11049358 2773388608
15:00:07 13141 .1601 3375184 8573819 11243469 2822110469
15:01:07 13915 .1696 3573952 8573819 11437580 2870832330
15:02:07 14688 .1790 3772192 8573819 11631192 2919428942
15:03:07 15456 .1883 3969648 8573819 11631192 2919428942
15:04:07 16222 .1977 4166520 8573819 11825303 2968150803
15:05:07 16990 .2070 4363536 8573819 12018915 3016747415
15:06:07 17753 .2163 4559656 8573819 12213026 3065469276
15:07:08 18516 .2256 4755752 8573819 12407137 3114191137
15:08:08 19279 .2349 4951360 8573819 12407137 3114191137
15:09:08 20040 .2442 5147208 8573819 12600749 3162787749
15:10:08 20799 .2535 5341976 8573819 12794860 3211509610
15:11:08 21557 .2627 5536408 8573819 12988472 3260106222
15:12:09 22314 .2719 5730896 8573819 13182583 3308828083
15:13:09 23071 .2812 5925328 8573819 13376694 3357549944
15:14:09 23830 .2904 6120280 8573819 13376694 3357549944
15:15:09 24584 .2996 6314064 8573819 13570306 3406146556
15:16:09 25340 .3088 6508136 8573819 13764417 3454868417
15:17:10 26095 .3180 6701680 8573819 13958029 3503465029
15:18:10 26849 .3272 6895224 8573819 14152140 3552186890
15:19:10 27600 .3364 7088816 8573819 14152140 3552186890
15:20:10 28351 .3455 7281688 8573819 14346251 3600908751
15:21:11 29104 .3547 7475152 8573819 14539863 3649505363
15:22:11 29855 .3639 7667536 8573819 14733974 3698227224
15:23:11 30605 .3730 7860008 8573819 14927586 3746823836
15:24:11 31352 .3821 8052320 8573819 14927586 3746823836
15:25:12 32099 .3912 8244464 8573819 15121697 3795545697
15:26:12 32846 .4003 8435944 8573819 15315808 3844267558
15:27:12 33591 .4094 8626840 8573819 15509420 3892864170
15:28:13 34333 .4184 8817720 8573819 15703531 3941586031
15:29:13 35077 .4275 9009040 8573819 15703531 3941586031
15:30:13 35823 .4366 9200608 8573819 15897143 3990182643
15:31:14 36569 .4457 9392192 8573819 16091254 4038904504
15:32:14 37310 .4547 9582096 8573819 16285365 4087626365
15:33:14 38049 .4637 9771904 8573819 16478977 4136222977
15:34:14 38785 .4727 9961296 8573819 16478977 4136222977
15:35:15 39525 .4817 10151616 8573819 16673088 4184944838
15:36:15 40263 .4907 10340856 8573819 16866700 4233541450
15:37:16 41001 .4997 10529528 8573819 17060811 4282263311
15:38:16 709 .0086 182056 17132168 17254423 35892627
15:39:16 1499 .0182 384896 17132168 17254423 35892627
15:40:16 2288 .0278 587624 17132168 17448534 84614488
15:41:16 3076 .0374 789976 17132168 17642645 133336349
15:42:16 3862 .0470 991712 17132168 17836257 181932961
15:43:16 4649 .0566 1193848 17132168 18030368 230654822
15:44:16 5436 .0662 1395992 17132168 18223980 279251434
15:45:16 6220 .0758 1597536 17132168 18418091 327973295
15:46:16 7003 .0853 1798432 17132168 18418091 327973295
15:47:17 7779 .0948 1997856 17132168 18612202 376695156
15:48:17 8559 .1043 2198408 17132168 18805814 425291768
15:49:17 9338 .1138 2398104 17132168 18999925 474013629
15:50:17 10116 .1233 2597872 17132168 19193537 522610241
15:51:17 10893 .1327 2797472 17132168 19387648 571332102
15:52:17 11668 .1422 2996608 17132168 19387648 571332102
15:53:17 12439 .1516 3194960 17132168 19581759 620053963
15:54:17 13211 .1610 3392840 17132168 19775371 668650575
15:55:18 13982 .1704 3590752 17132168 19969482 717372436
15:56:18 14750 .1797 3788000 17132168 20163094 765969048
15:57:18 15515 .1891 3984712 17132168 20357205 814690909
15:58:18 16281 .1984 4181208 17132168 20357205 814690909
15:59:18 17044 .2077 4377288 17132168 20551316 863412770
16:00:18 17801 .2169 4571904 17132168 20744928 912009382
16:01:19 18562 .2262 4767280 17132168 20939039 960731243
16:02:19 19319 .2354 4961480 17132168 21132651 1009327855
16:03:19 20076 .2447 5156208 17132168 21132651 1009327855
16:04:19 20832 .2539 5350368 17132168 21326762 1058049716
16:05:19 21586 .2631 5543904 17132168 21520873 1106771577
16:06:20 22341 .2723 5737528 17132168 21714485 1155368189
16:07:20 23095 .2815 5931600 17132168 21908596 1204090050
16:08:20 23847 .2906 6124600 17132168 22102208 1252686662
16:09:20 24600 .2998 6318064 17132168 22102208 1252686662
16:10:20 25352 .3090 6510992 17132168 22296319 1301408523
16:11:21 26102 .3181 6703912 17132168 22490430 1350130384
16:12:21 26851 .3272 6896232 17132168 22684042 1398726996
16:13:21 27601 .3364 7088656 17132168 22878153 1447448857
16:14:21 28351 .3455 7281224 17132168 22878153 1447448857
16:15:21 29098 .3546 7473200 17132168 23071765 1496045469
16:16:22 29845 .3637 7664880 17132168 23265876 1544767330
16:17:22 30592 .3728 7856680 17132168 23459987 1593489191
16:18:22 31333 .3819 8047128 17132168 23653599 1642085803
16:19:22 32078 .3910 8238720 17132168 23653599 1642085803
16:45:09 32789 .3996 8420928 17132168 23847710 1690807664
16:46:09 33521 .4085 8609216 17132168 24041322 1739404276
16:47:09 34251 .4174 8796608 17132168 24235433 1788126137
16:48:10 34982 .4264 8984168 17132168 24235433 1788126137
16:49:10 35717 .4353 9172992 17132168 24429544 1836847998
16:50:10 36449 .4442 9361568 17132168 24623156 1885444610
16:51:11 37178 .4531 9548648 17132168 24817267 1934166471
16:52:11 37897 .4619 9733592 17132168 25010879 1982763083
16:53:12 38605 .4705 9916072 17132168 25010879 1982763083
16:54:13 39308 .4791 10097320 17132168 25204990 2031484944
16:55:14 40016 .4877 10279208 17132168 25399101 2080206805
16:56:15 40722 .4963 10459216 17132168 25592713 2128803417
16:57:15 41440 .5051 10644712 17132168 25592713 2128803417
16:58:16 1120 .0136 287416 25695507 25786824 2177525278
16:59:16 1867 .0227 479272 25695507 25980436 2226121890
17:00:16 2613 .0318 670912 25695507 26174547 2274843751
17:01:16 3359 .0409 862512 25695507 26368658 2323565612
17:02:16 4113 .0501 1056144 25695507 26368658 2323565612
17:03:16 4866 .0593 1249600 25695507 26562270 2372162224
17:04:16 5610 .0683 1440672 25695507 26756381 2420884085
17:05:17 6352 .0774 1631152 25695507 26949993 2469480697
17:06:17 7106 .0866 1824688 25695507 27144104 2518202558
17:07:17 7860 .0958 2018624 25695507 27144104 2518202558
17:08:17 8611 .1049 2211320 25695507 27338215 2566924419
17:09:17 9362 .1141 2404544 25695507 27531827 2615521031
memberswrap-autovacuum-4.patch (application/octet-stream, 11.8K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..1d7d942 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2578,6 +2578,32 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..417ef64 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -105,10 +105,25 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(true);
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ {
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ params.multixact_freeze_table_age = max_multixact_age_to_avoid_member_wrap;
+ params.multixact_freeze_min_age = 0;
+ }
+ else
+ {
+ /* Use the default values. */
+ params.multixact_freeze_min_age = -1;
+ params.multixact_freeze_table_age = -1;
+ }
params.freeze_min_age = -1;
params.freeze_table_age = -1;
- params.multixact_freeze_min_age = -1;
- params.multixact_freeze_table_age = -1;
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..b5b8e3d 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int max_multixact_age_to_avoid_member_wrap);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_freeze_age_to_avoid_member_wrap,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1052,6 +1054,81 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the address space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return -1 to indicate
+ * that no special action needs to be taken. This should always be the case
+ * for users who don't make use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between the safe and dangerous levels, we return the current number of
+ * active multixids scaled down linearly for higher usage fractions, so that
+ * vacuuming becomes more aggressive as the member SLRU grows, in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we define the safe member count to be
+ * half of the member address space, and the dangerous level to be
+ * three-quarters. These numbers are lowered for manual invocations of
+ * vacuum, to give scheduled vacuum commands a head start, so they have a
+ * chance to tackle member space usage problems before autovacuum needs to be
+ * invoked.
+ */
+int
+compute_max_multixact_age_to_avoid_member_wrap(bool manual)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+ MultiXactOffset safe_member_count = MaxMultiXactOffset / 2;
+ MultiXactOffset dangerous_member_count = MaxMultiXactOffset -
+ (MaxMultiXactOffset / 4);
+
+ /* Give manual vacuum commands a head start before autovacuum jobs. */
+ if (manual)
+ {
+ safe_member_count /= 2;
+ dangerous_member_count /= 2;
+ }
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members <= safe_member_count)
+ {
+ /*
+ * There is no danger of member wrap, so return a number that is not
+ * lower than autovacuum_multixact_freeze_max_age.
+ */
+ return -1;
+ }
+
+ if (members >= dangerous_member_count)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ /*
+ * Choose a cutoff age which is a fraction of the approximate current
+ * number of active multixacts. If we are using an amount of member
+ * address space near safe_member_count, we use a number close to the
+ * number of active multixacts, so that only tables with the oldest
+ * relminmxid values become candidates for wraparound vacuums. As we get
+ * closer to dangerous_member_count, we use a number closer to zero, so
+ * that more tables become candidates for wraparound vacuums.
+ */
+ fraction = (double) (members - safe_member_count) /
+ (double) (dangerous_member_count - safe_member_count);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1077,6 +1154,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int max_multixact_age_to_avoid_member_wrap;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1196,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(false);
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ multiForceLimit = recentMulti - max_multixact_age_to_avoid_member_wrap;
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1964,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int max_multixact_age_to_avoid_member_wrap;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1975,6 +2059,14 @@ do_autovacuum(void)
relScan = heap_beginscan_catalog(classRel, 0, NULL);
/*
+ * Find the multixact age so that relation_needs_vacanalyze and
+ * table_recheck_autovac can detect cases where the multixact member space
+ * is in danger of being exhausted.
+ */
+ max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(false);
+
+ /*
* On the first pass, we collect main tables to vacuum, and also the main
* table relid to TOAST relid mapping.
*/
@@ -2001,6 +2093,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2222,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2329,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ max_multixact_age_to_avoid_member_wrap);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2537,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int max_multixact_age_to_avoid_member_wrap)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2584,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2647,16 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ {
+ multixact_freeze_table_age = max_multixact_age_to_avoid_member_wrap;
+ multixact_freeze_min_age = 0;
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2624,6 +2731,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int max_multixact_age_to_avoid_member_wrap,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2795,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ multixact_freeze_max_age = max_multixact_age_to_avoid_member_wrap;
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..0500435 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern void ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..6a71b5b 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int compute_max_multixact_age_to_avoid_member_wrap(bool manual);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-03 04:40 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 1 reply; 113+ messages in thread
From: Amit Kapila @ 2015-05-03 04:40 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Sat, May 2, 2015 at 11:46 AM, Thomas Munro <thomas.munro@enterprisedb.com>
wrote:
>
> On Sat, May 2, 2015 at 7:08 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> > On Fri, May 1, 2015 at 6:51 AM, Thomas Munro
> > <thomas.munro@enterprisedb.com> wrote:
> >> Those other places are for capping the effective table and tuple
> >> multixact freeze ages for manual vacuums, so that manual vacuums (say
> >> in nightly cronjobs) get a chance to run a wraparound scans before
> >> autovacuum kicks in at a less convenient time. So, yeah, I think we
> >> want to incorporate member wraparound prevention into that logic, and
> >> I will add that in the next version of the patch.
> >
> > +1. On a quick read-through of the patch, the biggest thing that
> > jumped out at me was that it only touches the autovacuum logic.
>
>
> Also attached is the output of the monitor.sh script posted upthread,
> while running explode_mxact_members.c. It looks better than the last
> results to me: whenever usage reaches 50%, autovacuum advances things
> such that usage drops right back to 0% (because it now uses
> multixact_freeze_min_age = 0) , and the system will happily chug on
> forever. What this test doesn't really show adequately is that if you
> had a lot of different tables and databases with different relminmxid
> values, they'd be vacuumed at different times. I should probably come
> up with a way to demonstrate that...
>
About data, I have extracted parts where there is a change in
oldest_mxid and segments
time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset
13:48:36 1 0 16 1 1 0
13:49:36 369 .0044 94752 1 1 0
..
14:44:04 41703 .5083 10713400 1 8528909 2140755909
14:45:05 1374 .0167 352960 8573819 8722521 2189352521
..
15:37:16 41001 .4997 10529528 8573819 17060811 4282263311
..
15:38:16 709 .0086 182056 17132168 17254423 35892627
..
16:57:15 41440 .5051 10644712 17132168 25592713 2128803417
..
16:58:16 1120 .0136 287416 25695507 25786824 2177525278
Based on this data, it seems that truncation of member space
as well as advancement of oldest multixact id happens once
it reaches 50% usage and at that time segments drops down to almost
zero. This happens repeatedly after 1 hour and in-between there
is no progress which indicates that all the work happens at
one go rather than in spreaded way. Won't this choke the system
when it happens due to I/O, isn't it better if we design it in a way such
that it is spreaded over period of time rather than doing everything at
one go?
--
+int
+compute_max_multixact_age_to_avoid_member_wrap(bool manual)
{
..
+ if (members <= safe_member_count)
+ {
+ /*
+ * There is no danger of
member wrap, so return a number that is not
+ * lower than autovacuum_multixact_freeze_max_age.
+
*/
+ return -1;
+ }
..
The above code doesn't seem to match its comments.
Comment says "..not lower than autovacuum_multixact_freeze_max_age",
but then return -1. It seems to me here we should return unchanged
autovacuum_multixact_freeze_max_age as it was coded in the initial
version of patch. Do you have any specific reason to change it?
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
@ 2015-05-03 23:49 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 06:47 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 19:06 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:59 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 4 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-03 23:49 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Sun, May 3, 2015 at 4:40 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> About data, I have extracted parts where there is a change in
> oldest_mxid and segments
>
> time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset
>
> 13:48:36 1 0 16 1 1 0
> 13:49:36 369 .0044 94752 1 1 0
> ..
> 14:44:04 41703 .5083 10713400 1 8528909 2140755909
>
> 14:45:05 1374 .0167 352960 8573819 8722521 2189352521
> ..
> 15:37:16 41001 .4997 10529528 8573819 17060811 4282263311
> ..
> 15:38:16 709 .0086 182056 17132168 17254423 35892627
> ..
> 16:57:15 41440 .5051 10644712 17132168 25592713 2128803417
> ..
> 16:58:16 1120 .0136 287416 25695507 25786824 2177525278
>
> Based on this data, it seems that truncation of member space
> as well as advancement of oldest multixact id happens once
> it reaches 50% usage and at that time segments drops down to almost
> zero. This happens repeatedly after 1 hour and in-between there
> is no progress which indicates that all the work happens at
> one go rather than in spreaded way. Won't this choke the system
> when it happens due to I/O, isn't it better if we design it in a way such
> that it is spreaded over period of time rather than doing everything at
> one go?
At 50% usage it starts vacuuming tables that have the very oldest mxid
in the system. That is, at 50% usage, we try to select the smallest
non-zero fraction of tables that can be selected based on relminmxid
alone, with any luck exactly one or close to it. As usage increases,
we decrease the cutoff age slowly so we start selecting tables with
slightly newer relminmxid values for vacuuming too. Only if it
reaches 75% usage will it vacuum everything it can and eat all your
IO. In a real system, I suppose there would be lots of big tables
that need to be vacuumed, the vacuuming would take some time, and they
would tend to have different relminmxids so that vacuuming would be
effectively spread out by this selection algorithm. I think. Perhaps
we should devise a test procedure to try to see if that happens. We'd
need to create a bunch of big tables and modify monitor.sh to show the
relminmxid for each of them so that you could see when they are being
processed -- I will look into that.
Restricting ourselves to selecting tables to vacuum using their
relminmxid alone makes this patch small since autovacuum already works
that way. We *could* introduce code that would be able to spread out
the work of vacuuming tables that happen to have identical or very
close relminmxid (say by introducing some non-determinism or doing
something weird based on hashing table oids and the time to explicitly
spread the start of processing over time, or <your idea here>), but I
didn't want to propose anything too big/complicated/clever/stupid and
I suspect that the relminmxid values will tend to diverge over time
(but I could be wrong about that, if they all start at 1 and then move
forward in lockstep over long periods of time then what I propose is
not good enough... let's see if we can find out).
> --
> +int
> +compute_max_multixact_age_to_avoid_member_wrap(bool manual)
> {
> ..
> + if (members <= safe_member_count)
> + {
> + /*
> + * There is no danger of
> member wrap, so return a number that is not
> + * lower than autovacuum_multixact_freeze_max_age.
> +
> */
> + return -1;
> + }
> ..
>
> The above code doesn't seem to match its comments.
> Comment says "..not lower than autovacuum_multixact_freeze_max_age",
> but then return -1. It seems to me here we should return unchanged
> autovacuum_multixact_freeze_max_age as it was coded in the initial
> version of patch. Do you have any specific reason to change it?
Oops, the comment is fixed in the attached patch.
In an earlier version, I was only dealing with the autovacuum case.
Now that the VACUUM command also calls it, I didn't want this
compute_max_multixact_age_to_avoid_member_wrap function to assume that
it was being called by autovacuum code and return the
autovacuum-specific GUC in the case that no special action is needed.
Also, the function no longer computes a value by scaling
autovacuum_multixact_freeze_max_age, it now scales the current number
of active multixacts, so that we can begin selecting a small non-zero
number of tables to vacuum as soon as we exceed safe_member_count as
described above (whereas when we used a scaled down
autovaccum_multixact_freeze_max_age, we usually didn't select any
tables at all until we scaled it down a lot, ie until we got close to
dangerous_member_count). Finally, I wanted a special value like -1
for 'none' so that table_recheck_autovac and ExecVacuum could use a
simple test >= 0 to know that they also need to set
multixact_freeze_min_age to zero in the case of a
member-space-triggered vacuum, so that we get maximum benefit from our
table scans by freezing all relevant tuples, not just some older ones
(that's why you see usage drop to almost zero each time, whereas the
monitor.sh results I showed from the earlier patch trimmed usage by
varying amounts, which meant that autovacuum wraparounds would need to
be done again sooner). Does that make sense?
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-autovacuum-5.patch (application/octet-stream, 11.8K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..1d7d942 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2578,6 +2578,32 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..417ef64 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -105,10 +105,25 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(true);
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ {
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ params.multixact_freeze_table_age = max_multixact_age_to_avoid_member_wrap;
+ params.multixact_freeze_min_age = 0;
+ }
+ else
+ {
+ /* Use the default values. */
+ params.multixact_freeze_min_age = -1;
+ params.multixact_freeze_table_age = -1;
+ }
params.freeze_min_age = -1;
params.freeze_table_age = -1;
- params.multixact_freeze_min_age = -1;
- params.multixact_freeze_table_age = -1;
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..96506d4 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int max_multixact_age_to_avoid_member_wrap);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_freeze_age_to_avoid_member_wrap,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1052,6 +1054,82 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the address space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return -1 to indicate
+ * that no special action needs to be taken. This should always be the case
+ * for users who don't make use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between the safe and dangerous levels, we return the current number of
+ * active multixids scaled down linearly for higher usage fractions, so that
+ * vacuuming becomes more aggressive as the member SLRU grows, in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we define the safe member count to be
+ * half of the member address space, and the dangerous level to be
+ * three-quarters. These numbers are lowered for manual invocations of
+ * vacuum, to give scheduled vacuum commands a head start, so they have a
+ * chance to tackle member space usage problems before autovacuum needs to be
+ * invoked.
+ */
+int
+compute_max_multixact_age_to_avoid_member_wrap(bool manual)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+ MultiXactOffset safe_member_count = MaxMultiXactOffset / 2;
+ MultiXactOffset dangerous_member_count = MaxMultiXactOffset -
+ (MaxMultiXactOffset / 4);
+
+ /* Give manual vacuum commands a head start before autovacuum jobs. */
+ if (manual)
+ {
+ safe_member_count /= 2;
+ dangerous_member_count /= 2;
+ }
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members <= safe_member_count)
+ {
+ /*
+ * There is no danger of member wrap. Return the special value that
+ * meeans there is no max multixact age needed to avoid member wrap,
+ * at present.
+ */
+ return -1;
+ }
+
+ if (members >= dangerous_member_count)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ /*
+ * Choose a cutoff age which is a fraction of the approximate current
+ * number of active multixacts. If we are using an amount of member
+ * address space near safe_member_count, we use a number close to the
+ * number of active multixacts, so that only tables with the oldest
+ * relminmxid values become candidates for wraparound vacuums. As we get
+ * closer to dangerous_member_count, we use a number closer to zero, so
+ * that more tables become candidates for wraparound vacuums.
+ */
+ fraction = (double) (members - safe_member_count) /
+ (double) (dangerous_member_count - safe_member_count);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1077,6 +1155,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int max_multixact_age_to_avoid_member_wrap;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1197,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(false);
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ multiForceLimit = recentMulti - max_multixact_age_to_avoid_member_wrap;
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1965,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int max_multixact_age_to_avoid_member_wrap;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1975,6 +2060,14 @@ do_autovacuum(void)
relScan = heap_beginscan_catalog(classRel, 0, NULL);
/*
+ * Find the multixact age so that relation_needs_vacanalyze and
+ * table_recheck_autovac can detect cases where the multixact member space
+ * is in danger of being exhausted.
+ */
+ max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(false);
+
+ /*
* On the first pass, we collect main tables to vacuum, and also the main
* table relid to TOAST relid mapping.
*/
@@ -2001,6 +2094,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2223,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2330,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ max_multixact_age_to_avoid_member_wrap);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2538,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int max_multixact_age_to_avoid_member_wrap)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2585,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ max_multixact_age_to_avoid_member_wrap,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2648,16 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ {
+ multixact_freeze_table_age = max_multixact_age_to_avoid_member_wrap;
+ multixact_freeze_min_age = 0;
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2624,6 +2732,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int max_multixact_age_to_avoid_member_wrap,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2796,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ multixact_freeze_max_age = max_multixact_age_to_avoid_member_wrap;
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..0500435 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern void ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..6a71b5b 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int compute_max_multixact_age_to_avoid_member_wrap(bool manual);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 06:25 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 07:12 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
3 siblings, 1 reply; 113+ messages in thread
From: Amit Kapila @ 2015-05-04 06:25 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Mon, May 4, 2015 at 5:19 AM, Thomas Munro <thomas.munro@enterprisedb.com>
wrote:
>
> On Sun, May 3, 2015 at 4:40 PM, Amit Kapila <amit.kapila16@gmail.com>
wrote:
> > --
> > +int
> > +compute_max_multixact_age_to_avoid_member_wrap(bool manual)
> > {
> > ..
> > + if (members <= safe_member_count)
> > + {
> > + /*
> > + * There is no danger of
> > member wrap, so return a number that is not
> > + * lower than autovacuum_multixact_freeze_max_age.
> > +
> > */
> > + return -1;
> > + }
> > ..
> >
> > The above code doesn't seem to match its comments.
> > Comment says "..not lower than autovacuum_multixact_freeze_max_age",
> > but then return -1. It seems to me here we should return unchanged
> > autovacuum_multixact_freeze_max_age as it was coded in the initial
> > version of patch. Do you have any specific reason to change it?
>
> Oops, the comment is fixed in the attached patch.
>
> In an earlier version, I was only dealing with the autovacuum case.
> Now that the VACUUM command also calls it, I didn't want this
> compute_max_multixact_age_to_avoid_member_wrap function to assume that
> it was being called by autovacuum code and return the
> autovacuum-specific GUC in the case that no special action is needed.
> Also, the function no longer computes a value by scaling
> autovacuum_multixact_freeze_max_age, it now scales the current number
> of active multixacts, so that we can begin selecting a small non-zero
> number of tables to vacuum as soon as we exceed safe_member_count as
> described above
I am slightly worried that if for scaling we don't consider the value for
multixact_*_age as configured by user, Vacuum/Autovacuum might
behave totally different from what user is expecting. Basically
it will be dominated based on member space usage and will ignore
the values set by user for multixact_*_age parameters. One way
could be to use minimum of the value calculated based on member
space and the value specified by user for multixact related parameters
as suggested in points 1 and 2 (below in mail).
One more thing, I think the current calculation considers members
usage, shouldn't we try to consider offset usage as well?
> (whereas when we used a scaled down
> autovaccum_multixact_freeze_max_age, we usually didn't select any
> tables at all until we scaled it down a lot, ie until we got close to
> dangerous_member_count). Finally, I wanted a special value like -1
> for 'none' so that table_recheck_autovac and ExecVacuum could use a
> simple test >= 0 to know that they also need to set
> multixact_freeze_min_age to zero in the case of a
> member-space-triggered vacuum, so that we get maximum benefit from our
> table scans by freezing all relevant tuples, not just some older ones
>
I think setting multixact_freeze_min_age to zero could be too aggresive
for I/O. Yes with this you can get maximum benefit, but at cost of
increased I/O. How would you justify setting it to zero as appropriate
w.r.t increased I/O?
Few more observations:
1.
@@ -2687,6 +2796,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts-
>multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
:
autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space.
*/
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ multixact_freeze_max_age =
max_multixact_age_to_avoid_member_wrap;
+
Isn't it better to use minimum to already computed value of
multixact_freeze_max_age and max_multixact_age_to_avoid_member_wrap?
multixact_freeze_max_age = Min(multixact_freeze_max_age,
max_multixact_age_to_avoid_member_wrap);
Similar change needs to be done in table_recheck_autovac()
2.
@@ -1118,7 +1197,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ max_multixact_age_to_avoid_member_wrap =
+ compute_max_multixact_age_to_avoid_member_wrap(false);
+ if (max_multixact_age_to_avoid_member_wrap >= 0)
+ multiForceLimit = recentMulti - max_multixact_age_to_avoid_member_wrap;
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
Here also, isn't it better to use minimum of
autovacuum_multixact_freeze_max_age
and max_multixact_age_to_avoid_member_wrap.
3.
+int
+compute_max_multixact_age_to_avoid_member_wrap(bool manual)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+ MultiXactOffset safe_member_count = MaxMultiXactOffset / 2;
It is not completely clear what is more appropriate value
for safe_member_count (25% or 50%). Anybody else have any
opinion on this value?
4. Once we conclude on final algorithm, we should update the
same in docs as well, probably in description at below link:
http://www.postgresql.org/docs/devel/static/routine-vacuuming.html#VACUUM-FOR-MULTIXACT-WRAPAROUND
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
@ 2015-05-04 07:12 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 11:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-04 07:12 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Mon, May 4, 2015 at 6:25 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> [...]
> One more thing, I think the current calculation considers members
> usage, shouldn't we try to consider offset usage as well?
Offsets are indexed by multixact ID:
#define MultiXactIdToOffsetPage(xid) \
((xid) / (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE)
#define MultiXactIdToOffsetEntry(xid) \
((xid) % (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE)
The existing multixact wraparound prevention code is already managing
the 32 bit multixact ID space. The problem with members comes about
because each one of those multixact IDs can have arbitrary numbers of
members, and yet the members are also addressed with a 32 bit index.
So we are trying to hijack the multixact ID wraparound prevention and
make it more aggressive if member space appears to be running out.
(Perhaps in future there should be a 64 bit index for member indexes
so that this problem disappears?)
>> (whereas when we used a scaled down
>> autovaccum_multixact_freeze_max_age, we usually didn't select any
>> tables at all until we scaled it down a lot, ie until we got close to
>> dangerous_member_count). Finally, I wanted a special value like -1
>> for 'none' so that table_recheck_autovac and ExecVacuum could use a
>> simple test >= 0 to know that they also need to set
>> multixact_freeze_min_age to zero in the case of a
>> member-space-triggered vacuum, so that we get maximum benefit from our
>> table scans by freezing all relevant tuples, not just some older ones
>>
>
> I think setting multixact_freeze_min_age to zero could be too aggresive
> for I/O. Yes with this you can get maximum benefit, but at cost of
> increased I/O. How would you justify setting it to zero as appropriate
> w.r.t increased I/O?
I assumed that if you were already vacuuming all your tablesto avoid
running out of member space, you would want to freeze any tuples you
possibly could to defer the next wraparound scan for as long as
possible, since wraparound scans are enormously expensive.
> Few more observations:
>
> 1.
> @@ -2687,6 +2796,10 @@ relation_needs_vacanalyze(Oid relid,
> ? Min(relopts-
>>multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
> :
> autovacuum_multixact_freeze_max_age;
>
> + /* Special settings if we are running out of member address space.
> */
> + if (max_multixact_age_to_avoid_member_wrap >= 0)
> + multixact_freeze_max_age =
> max_multixact_age_to_avoid_member_wrap;
> +
>
> Isn't it better to use minimum to already computed value of
> multixact_freeze_max_age and max_multixact_age_to_avoid_member_wrap?
>
> multixact_freeze_max_age = Min(multixact_freeze_max_age,
> max_multixact_age_to_avoid_member_wrap);
Except that I am using -1 as a special value. But you're right, I
guess it should be like this:
if (max_multixact_age_to_avoid_member_wrap >= 0)
multixact_freeze_max_age = Min(multixact_freeze_max_age,
max_multixact_age_to_avoid_member_wrap);
> Similar change needs to be done in table_recheck_autovac()
>
> 2.
> @@ -1118,7 +1197,12 @@ do_start_worker(void)
>
> /* Also determine the oldest datminmxid we will consider. */
> recentMulti = ReadNextMultiXactId();
> - multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
> + max_multixact_age_to_avoid_member_wrap =
> + compute_max_multixact_age_to_avoid_member_wrap(false);
> + if (max_multixact_age_to_avoid_member_wrap >= 0)
> + multiForceLimit = recentMulti - max_multixact_age_to_avoid_member_wrap;
> + else
> + multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
>
> Here also, isn't it better to use minimum of
> autovacuum_multixact_freeze_max_age
> and max_multixact_age_to_avoid_member_wrap.
Yeah, with the same proviso about -1.
> 3.
> +int
> +compute_max_multixact_age_to_avoid_member_wrap(bool manual)
> +{
> + MultiXactOffset members;
> + uint32 multixacts;
> + double fraction;
> + MultiXactOffset safe_member_count = MaxMultiXactOffset / 2;
>
> It is not completely clear what is more appropriate value
> for safe_member_count (25% or 50%). Anybody else have any
> opinion on this value?
>
> 4. Once we conclude on final algorithm, we should update the
> same in docs as well, probably in description at below link:
> http://www.postgresql.org/docs/devel/static/routine-vacuuming.html#VACUUM-FOR-MULTIXACT-WRAPAROUND
Agreed.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 07:12 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 11:49 ` Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 0 replies; 113+ messages in thread
From: Amit Kapila @ 2015-05-04 11:49 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Mon, May 4, 2015 at 12:42 PM, Thomas Munro <thomas.munro@enterprisedb.com>
wrote:
>
> On Mon, May 4, 2015 at 6:25 PM, Amit Kapila <amit.kapila16@gmail.com>
wrote:
> > [...]
> > One more thing, I think the current calculation considers members
> > usage, shouldn't we try to consider offset usage as well?
>
> Offsets are indexed by multixact ID:
>
> #define MultiXactIdToOffsetPage(xid) \
> ((xid) / (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE)
> #define MultiXactIdToOffsetEntry(xid) \
> ((xid) % (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE)
>
> The existing multixact wraparound prevention code is already managing
> the 32 bit multixact ID space. The problem with members comes about
> because each one of those multixact IDs can have arbitrary numbers of
> members, and yet the members are also addressed with a 32 bit index.
> So we are trying to hijack the multixact ID wraparound prevention and
> make it more aggressive if member space appears to be running out.
> (Perhaps in future there should be a 64 bit index for member indexes
> so that this problem disappears?)
>
Okay, that makes sense.
> >> (whereas when we used a scaled down
> >> autovaccum_multixact_freeze_max_age, we usually didn't select any
> >> tables at all until we scaled it down a lot, ie until we got close to
> >> dangerous_member_count). Finally, I wanted a special value like -1
> >> for 'none' so that table_recheck_autovac and ExecVacuum could use a
> >> simple test >= 0 to know that they also need to set
> >> multixact_freeze_min_age to zero in the case of a
> >> member-space-triggered vacuum, so that we get maximum benefit from our
> >> table scans by freezing all relevant tuples, not just some older ones
> >>
> >
> > I think setting multixact_freeze_min_age to zero could be too aggresive
> > for I/O. Yes with this you can get maximum benefit, but at cost of
> > increased I/O. How would you justify setting it to zero as appropriate
> > w.r.t increased I/O?
>
> I assumed that if you were already vacuuming all your tablesto avoid
> running out of member space,
I think here you mean all tables that has relminmxid lesser than the
newly computed age (compute_max_multixact_age_to_avoid_member_wrap)
> you would want to freeze any tuples you
> possibly could to defer the next wraparound scan for as long as
> possible, since wraparound scans are enormously expensive.
>
The point is valid to an extent, but If we go by this logic, then currently
also we should set multixact_freeze_min_age as zero for wraparound
vacuum.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 06:47 ` Thomas Munro <thomas.munro@enterprisedb.com>
3 siblings, 0 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-04 06:47 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Mon, May 4, 2015 at 11:49 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Sun, May 3, 2015 at 4:40 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>> Based on this data, it seems that truncation of member space
>> as well as advancement of oldest multixact id happens once
>> it reaches 50% usage and at that time segments drops down to almost
>> zero. This happens repeatedly after 1 hour and in-between there
>> is no progress which indicates that all the work happens at
>> one go rather than in spreaded way. Won't this choke the system
>> when it happens due to I/O, isn't it better if we design it in a way such
>> that it is spreaded over period of time rather than doing everything at
>> one go?
>
> At 50% usage it starts vacuuming tables that have the very oldest mxid
> in the system. That is, at 50% usage, we try to select the smallest
> non-zero fraction of tables that can be selected based on relminmxid
> alone, with any luck exactly one or close to it. As usage increases,
> we decrease the cutoff age slowly so we start selecting tables with
> slightly newer relminmxid values for vacuuming too. Only if it
> reaches 75% usage will it vacuum everything it can and eat all your
> IO. In a real system, I suppose there would be lots of big tables
> that need to be vacuumed, the vacuuming would take some time, and they
> would tend to have different relminmxids so that vacuuming would be
> effectively spread out by this selection algorithm. I think. Perhaps
> we should devise a test procedure to try to see if that happens. We'd
> need to create a bunch of big tables and modify monitor.sh to show the
> relminmxid for each of them so that you could see when they are being
> processed -- I will look into that.
After initdb, I did:
postgres=# create table foo as select 42 as id;
SELECT 1
postgres=# create table cat_a as select generate_series(1, 10000000);
SELECT 10000000
postgres=# create table cat_b as select generate_series(1, 10000000);
SELECT 10000000
postgres=# create table cat_c as select generate_series(1, 10000000);
SELECT 10000000
postgres=# create table cat_d as select generate_series(1, 10000000);
SELECT 10000000
Then I started monitor.sh (new version attached) and started
explode_mxact_members.c and recorded the attached file
monitor-output.txt. The result is not great: since relminmxid starts
at 1 for all tables created in a brand new database, 3
(autovacuum_max_workers) vacuums started around the same time, and
later they didn't really seem to be diverging, a bit under an hour
later the same three were triggered again, and so on.
I have also attached monitor-output-fail.txt, a case where the
database size is too large to be vacuumed fast enough for that rate of
member space consumption. It starts vacuuming with 3 workers at 50%,
and hasn't finished by 100%, so the new error is raised and no more
multixacts can be created. Eventually the vacuuming completes and
progress can be made. The database was set up as above, but the
tables have 10 times more rows.
> Restricting ourselves to selecting tables to vacuum using their
> relminmxid alone makes this patch small since autovacuum already works
> that way. We *could* introduce code that would be able to spread out
> the work of vacuuming tables that happen to have identical or very
> close relminmxid (say by introducing some non-determinism or doing
> something weird based on hashing table oids and the time to explicitly
> spread the start of processing over time, or <your idea here>), but I
> didn't want to propose anything too big/complicated/clever/stupid and
> I suspect that the relminmxid values will tend to diverge over time
> (but I could be wrong about that, if they all start at 1 and then move
> forward in lockstep over long periods of time then what I propose is
> not good enough... let's see if we can find out).
Maybe we do need to consider something more radical, since tables that
have the same relminmxid are fairly easy to produce (for example by
restoring a database dump into a new database). I will try to do
something that adds some noise to the signal to deal with this case
(of the top of my head, something along the lines of time_in_minutes %
16 == table_oid %16..., or adjust the multixact cutoff age with a
recipe including table_oid % something, or ... not sure yet). If
anyone has any better ideas, I am all ears.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
monitor-output-fail.txt (text/plain, 7.8K) download
time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset cat_a_relminmxid cat_b_relminmxid cat_c_relminmxid cat_d_relminmxid
12:24:32 1 0 16 1 1 0 1 1 1 1
12:25:32 266 .0032 68216 1 1 0 1 1 1 1
12:26:32 1024 .0124 262784 1 1 0 1 1 1 1
12:27:33 1792 .0218 460016 1 190619 47845119 1 1 1 1
12:28:33 2567 .0312 659088 1 384730 96566980 1 1 1 1
12:29:33 3346 .0407 859360 1 578342 145163592 1 1 1 1
12:30:33 4113 .0501 1056312 1 772453 193885453 1 1 1 1
12:31:33 4853 .0591 1246160 1 966065 242482065 1 1 1 1
12:32:33 5604 .0683 1439296 1 1160176 291203926 1 1 1 1
12:33:33 6340 .0772 1628016 1 1160176 291203926 1 1 1 1
12:34:33 7047 .0858 1809888 1 1354287 339925787 1 1 1 1
12:35:33 7777 .0947 1997288 1 1547899 388522399 1 1 1 1
12:36:33 8529 .1039 2190208 1 1742010 437244260 1 1 1 1
12:37:34 9287 .1132 2385120 1 1935622 485840872 1 1 1 1
12:38:34 10022 .1221 2573792 1 1935622 485840872 1 1 1 1
12:39:34 10781 .1314 2768728 1 2129733 534562733 1 1 1 1
12:40:34 11496 .1401 2952560 1 2323844 583284594 1 1 1 1
12:41:34 12235 .1491 3141928 1 2517456 631881206 1 1 1 1
12:42:34 12952 .1578 3326256 1 2517456 631881206 1 1 1 1
12:43:35 13709 .1671 3520976 1 2711567 680603067 1 1 1 1
12:44:35 14474 .1764 3717024 1 2905179 729199679 1 1 1 1
12:45:35 15227 .1856 3910560 1 3099290 777921540 1 1 1 1
12:46:35 15977 .1947 4103080 1 3293401 826643401 1 1 1 1
12:47:35 16710 .2036 4291496 1 3293401 826643401 1 1 1 1
12:48:35 17449 .2126 4481352 1 3487013 875240013 1 1 1 1
12:49:36 18186 .2216 4670592 1 3681124 923961874 1 1 1 1
12:50:36 18927 .2307 4861056 1 3874736 972558486 1 1 1 1
12:51:36 19665 .2397 5050656 1 4068847 1021280347 1 1 1 1
12:52:36 20393 .2485 5237720 1 4068847 1021280347 1 1 1 1
12:53:37 21134 .2576 5428776 1 4262958 1070002208 1 1 1 1
12:54:37 21884 .2667 5621640 1 4456570 1118598820 1 1 1 1
12:55:38 22636 .2759 5815040 1 4650681 1167320681 1 1 1 1
12:56:39 23389 .2850 6009032 1 4844293 1215917293 1 1 1 1
12:57:40 24144 .2942 6201848 1 4844293 1215917293 1 1 1 1
12:58:40 24894 .3034 6395104 1 5038404 1264639154 1 1 1 1
12:59:41 25645 .3125 6586952 1 5232515 1313361015 1 1 1 1
13:00:42 26388 .3216 6778648 1 5426127 1361957627 1 1 1 1
13:01:43 27137 .3307 6970752 1 5620238 1410679488 1 1 1 1
13:02:43 27879 .3398 7162000 1 5813850 1459276100 1 1 1 1
13:03:44 28630 .3489 7355592 1 5813850 1459276100 1 1 1 1
13:04:45 29360 .3578 7541760 1 6007961 1507997961 1 1 1 1
13:05:46 30076 .3666 7726080 1 6202072 1556719822 1 1 1 1
13:06:47 30795 .3753 7911632 1 6395684 1605316434 1 1 1 1
13:07:48 31494 .3838 8090352 1 6395684 1605316434 1 1 1 1
13:08:49 32236 .3929 8279080 1 6589795 1654038295 1 1 1 1
13:09:50 32963 .4017 8467728 1 6783407 1702634907 1 1 1 1
13:10:51 33710 .4108 8660600 1 6977518 1751356768 1 1 1 1
13:11:52 34425 .4196 8843512 1 7171629 1800078629 1 1 1 1
13:12:53 35148 .4284 9029248 1 7171629 1800078629 1 1 1 1
13:13:54 35891 .4374 9220696 1 7365241 1848675241 1 1 1 1
13:14:55 36638 .4465 9411664 1 7559352 1897397102 1 1 1 1
13:15:56 37383 .4556 9603528 1 7752964 1945993714 1 1 1 1
13:16:58 38119 .4646 9792472 1 7947075 1994715575 1 1 1 1
13:17:59 38860 .4736 9980376 1 7947075 1994715575 1 1 1 1
13:18:59 39587 .4825 10169120 1 8141186 2043437436 1 1 1 1
13:20:00 40315 .4914 10355808 1 8334798 2092034048 1 1 1 1
13:21:02 41042 .5002 10544256 1 8528909 2140755909 1 1 1 1
13:22:03 41775 .5092 10728944 1 8528909 2140755909 1 1 1 1
13:23:04 42492 .5179 10915488 1 8722022 2189227272 1 1 1 1
13:24:05 43215 .5267 11101608 1 8915135 2237698635 1 1 1 1
13:25:06 43937 .5355 11288064 1 9108248 2286169998 1 1 1 1
13:26:08 44660 .5443 11472760 1 9301361 2334641361 1 1 1 1
13:27:09 45368 .5529 11654880 1 9301361 2334641361 1 1 1 1
13:28:11 46076 .5616 11837408 1 9494474 2383112724 1 1 1 1
13:29:12 46782 .5702 12017744 1 9687587 2431584087 1 1 1 1
13:30:13 47485 .5788 12198536 1 9880700 2480055450 1 1 1 1
13:31:15 48205 .5875 12384552 1 9880700 2480055450 1 1 1 1
13:32:17 48921 .5963 12566512 1 10073314 2528401564 1 1 1 1
13:33:18 49622 .6048 12747672 1 10266427 2576872927 1 1 1 1
13:34:19 50327 .6134 12928792 1 10459540 2625344290 1 1 1 1
13:35:21 51036 .6220 13107720 1 10459540 2625344290 1 1 1 1
13:36:21 51707 .6302 13282224 1 10652653 2673815653 1 1 1 1
13:37:23 52353 .6381 13448728 1 10845766 2722287016 1 1 1 1
13:38:25 53008 .6461 13618560 1 11038879 2770758379 1 1 1 1
13:39:27 53720 .6548 13796960 1 11038879 2770758379 1 1 1 1
13:40:27 54414 .6632 13978344 1 11231493 2819104493 1 1 1 1
13:41:29 55117 .6718 14158976 1 11424606 2867575856 1 1 1 1
13:42:31 55819 .6803 14340856 1 11617719 2916047219 1 1 1 1
13:43:33 56528 .6890 14521360 1 11617719 2916047219 1 1 1 1
13:44:34 57231 .6975 14702168 1 11810832 2964518582 1 1 1 1
13:45:36 57936 .7061 14883992 1 12003945 3012989945 1 1 1 1
13:46:38 58645 .7148 15062176 1 12197058 3061461308 1 1 1 1
13:47:39 59335 .7232 15242808 1 12197058 3061461308 1 1 1 1
13:48:40 60043 .7318 15424808 1 12390171 3109932671 1 1 1 1
13:49:42 60746 .7404 15607048 1 12582785 3158278785 1 1 1 1
13:50:45 61453 .7490 15782872 1 12775898 3206750148 1 1 1 1
13:51:45 62156 .7576 15970368 1 12969011 3255221511 1 1 1 1
13:52:48 62938 .7671 16169344 1 12969011 3255221511 1 1 1 1
13:53:50 63718 .7766 16364728 1 13162124 3303692874 1 1 1 1
13:54:51 64481 .7859 16560728 1 13355237 3352164237 1 1 1 1
13:55:51 65247 .7953 16757336 1 13548350 3400635600 1 1 1 1
13:56:52 66001 .8044 16950272 1 13741463 3449106963 1 1 1 1
13:57:52 66711 .8131 17133160 1 13741463 3449106963 1 1 1 1
13:58:53 67369 .8211 17302352 1 13934576 3497578326 1 1 1 1
13:59:54 68027 .8291 17470672 1 14127689 3546049689 1 1 1 1
14:00:54 68717 .8376 17647744 1 14320802 3594521052 1 1 1 1
14:01:54 69378 .8456 17818432 1 14320802 3594521052 1 1 1 1
14:02:55 70003 .8532 17978176 1 14513915 3642992415 1 1 1 1
14:03:56 70661 .8612 18146952 1 14706529 3691338529 1 1 1 1
14:04:56 71338 .8695 18321760 1 14706529 3691338529 1 1 1 1
14:05:57 72025 .8779 18497392 1 14899642 3739809892 1 1 1 1
14:06:57 72682 .8859 18666320 1 15092755 3788281255 1 1 1 1
14:07:58 73355 .8941 18838976 1 15285868 3836752618 1 1 1 1
14:08:58 74025 .9023 19011624 1 15285868 3836752618 1 1 1 1
14:09:59 74699 .9105 19184008 1 15478482 3885098732 1 1 1 1
14:10:59 75374 .9187 19357536 1 15671595 3933570095 1 1 1 1
14:12:00 76009 .9264 19521584 1 15671595 3933570095 1 1 1 1
14:13:01 76668 .9345 19690528 1 15864708 3982041458 1 1 1 1
14:14:02 77345 .9427 19863816 1 16057821 4030512821 1 1 1 1
14:15:02 78015 .9509 20035848 1 16250934 4078984184 1 1 1 1
14:16:02 78684 .9590 20208504 1 16250934 4078984184 1 1 1 1
14:17:03 79362 .9673 20381832 1 16443548 4127330298 1 1 1 1
14:18:04 80035 .9755 20554824 1 16636661 4175801661 1 1 1 1
14:19:05 80707 .9837 20727608 1 16829774 4224273024 1 1 1 1
14:20:05 81379 .9919 20899880 1 16829774 4224273024 1 1 1 1
14:21:06 82039 .9999 21068688 1 17022887 4272744387 1 1 1 1
14:22:07 82039 .9999 21068688 1 17022887 4272744387 1 1 1 1
14:23:07 82039 .9999 21068688 1 17022887 4272744387 1 1 1 1
14:24:07 82039 .9999 21068688 1 17022887 4272744387 1 1 1 1
14:25:08 82039 .9999 21068688 1 17022887 4272744387 1 1 1 1
14:26:08 82040 1.0000 21068880 1 17111263 4294914944 1 1 1 1
14:27:09 82040 1.0000 21068880 1 17111263 4294914944 1 1 1 1
14:28:09 82040 1.0000 21068880 1 17111263 4294914944 1 1 1 1
14:29:10 82040 1.0000 21068880 1 17111263 4294914944 1 1 1 1
14:30:10 82040 1.0000 21068880 1 17111263 4294914944 1 1 1 1
14:31:11 82040 1.0000 21068880 1 17111263 4294914944 1 1 1 1
14:32:11 82040 1.0000 21068880 1 17111263 4294914944 8602262 8610745 8619228 1
14:33:12 82040 1.0000 21068880 1 17111263 4294914944 8602262 8610745 8619228 1
14:34:13 82040 1.0000 21068880 1 17111263 4294914944 8602262 8610745 8619228 1
14:35:14 82040 1.0000 21068880 1 17111263 4294914944 8602262 8610745 8619228 1
14:36:14 82040 1.0000 21068880 1 17111263 4294914944 8602262 8610745 8619228 1
14:37:15 82040 1.0000 21068880 1 17111263 4294914944 8602262 8610745 8619228 1
monitor.sh (application/x-sh, 1.4K) download
monitor-output.txt (text/plain, 19.9K) download
time segments usage_fraction usage_kb oldest_mxid next_mxid next_offset cat_a_relminmxid cat_b_relminmxid cat_c_relminmxid cat_d_relminmxid
14:39:55 1 0 16 1 1 0 1 1 1 1
14:40:55 584 .0071 149760 1 1 0 1 1 1 1
14:41:55 1325 .0161 340200 1 190619 47845119 1 1 1 1
14:42:55 2072 .0252 531904 1 384730 96566980 1 1 1 1
14:43:55 2820 .0343 724080 1 384730 96566980 1 1 1 1
14:44:55 3572 .0435 917144 1 578342 145163592 1 1 1 1
14:45:56 4326 .0527 1110760 1 772453 193885453 1 1 1 1
14:46:56 5082 .0619 1304864 1 772453 193885453 1 1 1 1
14:47:56 5841 .0711 1500024 1 1160176 291203926 1 1 1 1
14:48:56 6599 .0804 1694872 1 1354287 339925787 1 1 1 1
14:49:56 7357 .0896 1889152 1 1354287 339925787 1 1 1 1
14:50:56 8114 .0989 2083848 1 1547899 388522399 1 1 1 1
14:51:56 8871 .1081 2278352 1 1742010 437244260 1 1 1 1
14:52:56 9630 .1173 2473296 1 1935622 485840872 1 1 1 1
14:53:56 10388 .1266 2667928 1 2129733 534562733 1 1 1 1
14:54:56 11144 .1358 2862040 1 2323844 583284594 1 1 1 1
14:55:56 11903 .1450 3056832 1 2323844 583284594 1 1 1 1
14:56:57 12659 .1543 3250968 1 2517456 631881206 1 1 1 1
14:57:57 13413 .1634 3444840 1 2711567 680603067 1 1 1 1
14:58:57 14165 .1726 3637760 1 2905179 729199679 1 1 1 1
14:59:57 14916 .1818 3830704 1 3099290 777921540 1 1 1 1
15:00:57 15672 .1910 4024840 1 3099290 777921540 1 1 1 1
15:01:58 16443 .2004 4222704 1 3293401 826643401 1 1 1 1
15:02:58 17209 .2097 4419904 1 3487013 875240013 1 1 1 1
15:03:58 17977 .2191 4616704 1 3681124 923961874 1 1 1 1
15:04:58 18740 .2284 4812944 1 3874736 972558486 1 1 1 1
15:05:58 19506 .2377 5009536 1 3874736 972558486 1 1 1 1
15:06:59 20269 .2470 5205640 1 4068847 1021280347 1 1 1 1
15:07:59 21032 .2563 5401672 1 4262958 1070002208 1 1 1 1
15:08:59 21792 .2656 5596520 1 4456570 1118598820 1 1 1 1
15:09:59 22552 .2748 5791888 1 4650681 1167320681 1 1 1 1
15:10:59 23312 .2841 5986976 1 4844293 1215917293 1 1 1 1
15:12:00 24075 .2934 6182984 1 4844293 1215917293 1 1 1 1
15:13:00 24837 .3027 6378688 1 5038404 1264639154 1 1 1 1
15:14:00 25592 .3119 6572440 1 5232515 1313361015 1 1 1 1
15:15:00 26347 .3211 6766464 1 5426127 1361957627 1 1 1 1
15:16:01 27102 .3303 6960520 1 5620238 1410679488 1 1 1 1
15:17:01 27855 .3395 7153576 1 5620238 1410679488 1 1 1 1
15:18:01 28609 .3487 7347592 1 5813850 1459276100 1 1 1 1
15:19:01 29363 .3579 7541144 1 6007961 1507997961 1 1 1 1
15:20:02 30116 .3670 7734288 1 6202072 1556719822 1 1 1 1
15:21:02 30865 .3762 7926872 1 6395684 1605316434 1 1 1 1
15:22:02 31614 .3853 8119192 1 6589795 1654038295 1 1 1 1
15:23:02 32365 .3945 8312232 1 6589795 1654038295 1 1 1 1
15:24:03 33112 .4036 8503984 1 6783407 1702634907 1 1 1 1
15:25:03 33862 .4127 8696568 1 6977518 1751356768 1 1 1 1
15:26:04 34607 .4218 8887936 1 7171629 1800078629 1 1 1 1
15:27:04 35352 .4309 9079192 1 7365241 1848675241 1 1 1 1
15:28:04 36073 .4397 9264576 1 7365241 1848675241 1 1 1 1
15:29:04 36803 .4485 9451936 1 7559352 1897397102 1 1 1 1
15:30:05 37535 .4575 9639976 1 7752964 1945993714 1 1 1 1
15:31:05 38267 .4664 9827984 1 7947075 1994715575 1 1 1 1
15:32:05 39002 .4754 10016616 1 7947075 1994715575 1 1 1 1
15:33:06 39736 .4843 10205240 1 8141186 2043437436 1 1 1 1
15:34:06 40468 .4932 10393248 1 8334798 2092034048 1 1 1 1
15:35:07 41203 .5022 10581872 1 8528909 2140755909 1 1 1 1
15:36:07 41923 .5110 10766808 1 8722022 2189227272 1 1 1 1
15:37:07 42633 .5196 10949288 1 8722022 2189227272 1 1 1 1
15:38:08 43340 .5282 11130760 1 8915135 2237698635 1 1 1 1
15:39:08 44030 .5366 11308104 1 9108248 2286169998 1 1 1 1
15:40:08 44722 .5451 11485664 1 9301361 2334641361 1 1 1 1
15:41:09 45416 .5535 11663904 1 9301361 2334641361 1 1 1 1
15:42:09 46110 .5620 11842136 1 9494474 2383112724 8605256 8613739 1 1
15:43:10 46811 .5705 12022200 1 9494474 2383112724 8605256 8613739 8622222 1
15:44:10 47504 .5790 12200176 1 9880201 2479930201 8605256 8613739 8622222 1
15:45:11 48196 .5874 12377800 1 9880201 2479930201 8605256 8613739 8622222 9586789
15:46:11 7817 .0952 2007704 8565835 10073813 2528526813 8605256 8613739 8622222 9586789
15:47:11 8552 .1042 2196544 8565835 10267924 2577248674 8605256 8613739 8622222 9586789
15:48:11 9277 .1130 2382608 8565835 10461536 2625845286 8605256 8613739 8622222 9586789
15:49:11 10013 .1220 2571600 8565835 10461536 2625845286 8605256 8613739 8622222 9586789
15:50:11 10742 .1309 2758880 8565835 10655647 2674567147 8605256 8613739 8622222 9586789
15:51:12 11449 .1395 2940408 8565835 10849758 2723289008 8605256 8613739 8622222 9586789
15:52:12 12171 .1483 3125872 8565835 11043370 2771885620 8605256 8613739 8622222 9586789
15:53:12 12915 .1574 3317112 8565835 11237481 2820607481 8605256 8613739 8622222 9586789
15:54:12 13661 .1665 3508600 8565835 11237481 2820607481 8605256 8613739 8622222 9586789
15:55:12 14405 .1755 3699544 8565835 11431093 2869204093 8605256 8613739 8622222 9586789
15:56:12 15098 .1840 3877728 8565835 11625204 2917925954 8605256 8613739 8622222 9586789
15:57:13 15834 .1930 4066520 8565835 11819315 2966647815 8605256 8613739 8622222 9586789
15:58:13 16567 .2019 4255000 8565835 12012927 3015244427 8605256 8613739 8622222 9586789
15:59:13 17291 .2107 4441144 8565835 12012927 3015244427 8605256 8613739 8622222 9586789
16:00:13 18011 .2195 4625936 8565835 12207038 3063966288 8605256 8613739 8622222 9586789
16:01:13 18744 .2284 4814096 8565835 12400650 3112562900 8605256 8613739 8622222 9586789
16:02:13 19472 .2373 5000880 8565835 12594761 3161284761 8605256 8613739 8622222 9586789
16:03:14 20201 .2462 5188272 8565835 12594761 3161284761 8605256 8613739 8622222 9586789
16:04:14 20933 .2551 5376280 8565835 12788872 3210006622 8605256 8613739 8622222 9586789
16:05:14 21662 .2640 5563144 8565835 12982484 3258603234 8605256 8613739 8622222 9586789
16:06:14 22387 .2728 5749624 8565835 13176595 3307325095 8605256 8613739 8622222 9586789
16:07:15 23113 .2817 5936016 8565835 13370207 3355921707 8605256 8613739 8622222 9586789
16:08:15 23841 .2906 6123224 8565835 13370207 3355921707 8605256 8613739 8622222 9586789
16:09:15 24568 .2994 6309936 8565835 13564318 3404643568 8605256 8613739 8622222 9586789
16:10:15 25291 .3082 6495680 8565835 13758429 3453365429 8605256 8613739 8622222 9586789
16:11:16 25985 .3167 6673304 8565835 13952041 3501962041 8605256 8613739 8622222 9586789
16:12:16 26661 .3249 6847384 8565835 13952041 3501962041 8605256 8613739 8622222 9586789
16:13:16 27308 .3328 7013696 8565835 14146152 3550683902 8605256 8613739 8622222 9586789
16:14:17 27989 .3411 7188192 8565835 14339764 3599280514 8605256 8613739 8622222 9586789
16:15:17 28669 .3494 7362704 8565835 14533875 3648002375 8605256 8613739 8622222 9586789
16:16:17 29321 .3573 7530504 8565835 14533875 3648002375 8605256 8613739 8622222 9586789
16:17:17 30004 .3657 7705672 8565835 14727986 3696724236 8605256 8613739 8622222 9586789
16:18:18 30703 .3742 7885496 8565835 14921598 3745320848 8605256 8613739 8622222 9586789
16:19:18 31411 .3828 8066864 8565835 15115709 3794042709 8605256 8613739 8622222 9586789
16:20:18 32117 .3914 8248760 8565835 15115709 3794042709 8605256 8613739 8622222 9586789
16:21:19 32820 .4000 8429304 8565835 15309321 3842639321 8605256 8613739 8622222 9586789
16:22:19 33504 .4083 8604448 8565835 15503432 3891361182 8605256 8613739 8622222 9586789
16:23:19 34173 .4165 8776640 8565835 15503432 3891361182 8605256 8613739 8622222 9586789
16:24:20 34860 .4249 8953320 8565835 15697543 3940083043 8605256 8613739 8622222 9586789
16:25:20 35561 .4334 9133176 8565835 15891155 3988679655 8605256 8613739 8622222 9586789
16:26:20 36265 .4420 9313728 8565835 16085266 4037401516 8605256 8613739 8622222 9586789
16:27:21 36965 .4505 9493912 8565835 16085266 4037401516 8605256 8613739 8622222 9586789
16:28:21 37670 .4591 9674808 8565835 16278878 4085998128 8605256 8613739 8622222 9586789
16:29:22 38371 .4677 9854832 8565835 16472989 4134719989 8605256 8613739 8622222 9586789
16:30:22 39072 .4762 10034768 8565835 16667100 4183441850 8605256 8613739 8622222 9586789
16:31:22 39735 .4843 10204960 8565835 16667100 4183441850 8605256 8613739 8622222 9586789
16:32:23 40378 .4921 10370232 8565835 16860712 4232038462 8605256 8613739 8622222 9586789
16:33:23 41025 .5000 10535736 8565835 17054823 4280760323 8605256 8613739 8622222 9586789
16:34:23 41495 .5057 10656472 8605256 17248435 34389639 8605256 8613739 8622222 9586789
16:35:24 42144 .5137 10823432 8605256 17248435 34389639 8605256 8613739 8622222 9586789
16:36:24 42790 .5215 10989152 8605256 17442546 83111500 17165102 17172587 17181070 9586789
16:37:24 38737 .4721 9948360 9586789 17636657 131833361 17165102 17172587 17181070 9586789
16:38:25 39393 .4801 10116984 9586789 17636657 131833361 17165102 17172587 17181070 9586789
16:39:25 40056 .4882 10287168 9586789 17830269 180429973 17165102 17172587 17181070 9586789
16:40:26 40731 .4964 10460440 9586789 18024380 229151834 17165102 17172587 17181070 9586789
16:41:26 41407 .5047 10634352 9586789 18217992 277748446 17165102 17172587 17181070 9586789
16:42:26 42070 .5127 10804504 9586789 18217992 277748446 17165102 17172587 17181070 18142144
16:43:27 6603 .0804 1695808 17125182 18412103 326470307 17165102 17172587 17181070 18142144
16:44:27 7309 .0890 1877184 17125182 18606214 375192168 17165102 17172587 17181070 18142144
16:45:27 8001 .0975 2054856 17125182 18606214 375192168 17165102 17172587 17181070 18142144
16:46:27 8701 .1060 2234776 17125182 18799826 423788780 17165102 17172587 17181070 18142144
16:47:27 9432 .1149 2422168 17125182 18993937 472510641 17165102 17172587 17181070 18142144
16:48:28 10138 .1235 2603832 17125182 19187549 521107253 17165102 17172587 17181070 18142144
16:49:28 10883 .1326 2795064 17125182 19381660 569829114 17165102 17172587 17181070 18142144
16:50:28 11584 .1411 2975136 17125182 19381660 569829114 17165102 17172587 17181070 18142144
16:51:28 12281 .1496 3153936 17125182 19575771 618550975 17165102 17172587 17181070 18142144
16:52:29 12971 .1581 3331240 17125182 19769383 667147587 17165102 17172587 17181070 18142144
16:53:29 13664 .1665 3509424 17125182 19963494 715869448 17165102 17172587 17181070 18142144
16:54:29 14336 .1747 3681712 17125182 19963494 715869448 17165102 17172587 17181070 18142144
16:55:29 15002 .1828 3853048 17125182 20157106 764466060 17165102 17172587 17181070 18142144
16:56:29 15722 .1916 4038080 17125182 20351217 813187921 17165102 17172587 17181070 18142144
16:57:29 16451 .2005 4225192 17125182 20545328 861909782 17165102 17172587 17181070 18142144
16:58:30 17178 .2093 4411648 17125182 20545328 861909782 17165102 17172587 17181070 18142144
16:59:30 17901 .2181 4597208 17125182 20738940 910506394 17165102 17172587 17181070 18142144
17:00:30 18619 .2269 4781528 17125182 20933051 959228255 17165102 17172587 17181070 18142144
17:01:30 19332 .2356 4964992 17125182 21126663 1007824867 17165102 17172587 17181070 18142144
17:02:31 20042 .2442 5147088 17125182 21126663 1007824867 17165102 17172587 17181070 18142144
17:03:31 20748 .2529 5328360 17125182 21320774 1056546728 17165102 17172587 17181070 18142144
17:04:31 21428 .2611 5503456 17125182 21514885 1105268589 17165102 17172587 17181070 18142144
17:05:32 22130 .2697 5683480 17125182 21708497 1153865201 17165102 17172587 17181070 18142144
17:06:32 22839 .2783 5865504 17125182 21708497 1153865201 17165102 17172587 17181070 18142144
17:07:32 23552 .2870 6048528 17125182 21902608 1202587062 17165102 17172587 17181070 18142144
17:08:33 24259 .2956 6230304 17125182 22096220 1251183674 17165102 17172587 17181070 18142144
17:09:33 24911 .3036 6397784 17125182 22290331 1299905535 17165102 17172587 17181070 18142144
17:10:33 25607 .3121 6576808 17125182 22290331 1299905535 17165102 17172587 17181070 18142144
17:11:34 26315 .3207 6758280 17125182 22484442 1348627396 17165102 17172587 17181070 18142144
17:12:34 27028 .3294 6941680 17125182 22678054 1397224008 17165102 17172587 17181070 18142144
17:13:34 27741 .3381 7124480 17125182 22872165 1445945869 17165102 17172587 17181070 18142144
17:14:35 28440 .3466 7304304 17125182 22872165 1445945869 17165102 17172587 17181070 18142144
17:15:35 29145 .3552 7485024 17125182 23065777 1494542481 17165102 17172587 17181070 18142144
17:16:36 29836 .3636 7662544 17125182 23259888 1543264342 17165102 17172587 17181070 18142144
17:17:36 30537 .3722 7842552 17125182 23453999 1591986203 17165102 17172587 17181070 18142144
17:18:36 31237 .3807 8022496 17125182 23453999 1591986203 17165102 17172587 17181070 18142144
17:19:37 31933 .3892 8200992 17125182 23647611 1640582815 17165102 17172587 17181070 18142144
17:20:37 32639 .3978 8382600 17125182 23841722 1689304676 17165102 17172587 17181070 18142144
17:21:37 33327 .4062 8559120 17125182 24035334 1737901288 17165102 17172587 17181070 18142144
17:22:38 34029 .4147 8739464 17125182 24035334 1737901288 17165102 17172587 17181070 18142144
17:23:38 34732 .4233 8919912 17125182 24229445 1786623149 17165102 17172587 17181070 18142144
17:24:39 35433 .4318 9100232 17125182 24423556 1835345010 17165102 17172587 17181070 18142144
17:25:39 36111 .4401 9274224 17125182 24617168 1883941622 17165102 17172587 17181070 18142144
17:26:40 36777 .4482 9445232 17125182 24617168 1883941622 17165102 17172587 17181070 18142144
17:27:40 37462 .4566 9621256 17125182 24811279 1932663483 17165102 17172587 17181070 18142144
17:28:40 38166 .4652 9801960 17125182 25004891 1981260095 17165102 17172587 17181070 18142144
17:29:41 38863 .4737 9980960 17125182 25199002 2029981956 17165102 17172587 17181070 18142144
17:30:41 39558 .4821 10159480 17125182 25199002 2029981956 17165102 17172587 17181070 18142144
17:31:41 40248 .4905 10336616 17125182 25393113 2078703817 17165102 17172587 17181070 18142144
17:32:41 40957 .4992 10518760 17125182 25586725 2127300429 17165102 17172587 17181070 18142144
17:33:42 41473 .5055 10651640 17165102 25780836 2176022290 17165102 17172587 17181070 18142144
17:34:42 42176 .5140 10832032 17165102 25780836 2176022290 17165102 17172587 17181070 18142144
17:35:42 42891 .5228 11015568 17165102 25974448 2224618902 25723950 25732433 25740916 18142144
17:36:43 38919 .4743 9995608 18142144 26168559 2273340763 25723950 25732433 25740916 18142144
17:37:43 39627 .4830 10177376 18142144 26362171 2321937375 25723950 25732433 25740916 18142144
17:38:43 40333 .4916 10358808 18142144 26362171 2321937375 25723950 25732433 25740916 18142144
17:39:44 41043 .5002 10541120 18142144 26556282 2370659236 25723950 25732433 25740916 18142144
17:40:45 41760 .5090 10725120 18142144 26750393 2419381097 25723950 25732433 25740916 26699495
17:41:45 6288 .0766 1615144 25689519 26944005 2467977709 25723950 25732433 25740916 26699495
17:42:45 7001 .0853 1798016 25689519 27138116 2516699570 25723950 25732433 25740916 26699495
17:43:45 7730 .0942 1985344 25689519 27138116 2516699570 25723950 25732433 25740916 26699495
17:44:45 8453 .1030 2170904 25689519 27331728 2565296182 25723950 25732433 25740916 26699495
17:45:46 9176 .1118 2356808 25689519 27525839 2614018043 25723950 25732433 25740916 26699495
17:46:46 9910 .1207 2545248 25689519 27719950 2662739904 25723950 25732433 25740916 26699495
17:47:46 10651 .1298 2735552 25689519 27719950 2662739904 25723950 25732433 25740916 26699495
17:48:46 11374 .1386 2921304 25689519 27913562 2711336516 25723950 25732433 25740916 26699495
17:49:46 12093 .1474 3106040 25689519 28107673 2760058377 25723950 25732433 25740916 26699495
17:50:46 12806 .1560 3289136 25689519 28301285 2808654989 25723950 25732433 25740916 26699495
17:51:46 13521 .1648 3472848 25689519 28495396 2857376850 25723950 25732433 25740916 26699495
17:52:47 14231 .1734 3655216 25689519 28495396 2857376850 25723950 25732433 25740916 26699495
17:53:47 14949 .1822 3839552 25689519 28689507 2906098711 25723950 25732433 25740916 26699495
17:54:47 15673 .1910 4025200 25689519 28883119 2954695323 25723950 25732433 25740916 26699495
17:55:47 16385 .1997 4208304 25689519 29077230 3003417184 25723950 25732433 25740916 26699495
17:56:47 17070 .2080 4384112 25689519 29077230 3003417184 25723950 25732433 25740916 26699495
17:57:48 17779 .2167 4566248 25689519 29270842 3052013796 25723950 25732433 25740916 26699495
17:58:48 18477 .2252 4745512 25689519 29464953 3100735657 25723950 25732433 25740916 26699495
17:59:48 19193 .2339 4929400 25689519 29659064 3149457518 25723950 25732433 25740916 26699495
18:00:48 19915 .2427 5114568 25689519 29659064 3149457518 25723950 25732433 25740916 26699495
18:01:48 20628 .2514 5297816 25689519 29852676 3198054130 25723950 25732433 25740916 26699495
18:02:49 21348 .2602 5482640 25689519 30046787 3246775991 25723950 25732433 25740916 26699495
18:03:49 22058 .2688 5665128 25689519 30240399 3295372603 25723950 25732433 25740916 26699495
18:04:49 22764 .2774 5846496 25689519 30434510 3344094464 25723950 25732433 25740916 26699495
18:05:49 23468 .2860 6027456 25689519 30434510 3344094464 25723950 25732433 25740916 26699495
18:06:50 24174 .2946 6208432 25689519 30628621 3392816325 25723950 25732433 25740916 26699495
18:07:50 24870 .3031 6387128 25689519 30822233 3441412937 25723950 25732433 25740916 26699495
18:08:50 25571 .3116 6567544 25689519 31016344 3490134798 25723950 25732433 25740916 26699495
18:09:50 26277 .3202 6748904 25689519 31016344 3490134798 25723950 25732433 25740916 26699495
18:10:51 26981 .3288 6929712 25689519 31209956 3538731410 25723950 25732433 25740916 26699495
18:11:51 27683 .3374 7109568 25689519 31404067 3587453271 25723950 25732433 25740916 26699495
18:12:51 28387 .3460 7290496 25689519 31598178 3636175132 25723950 25732433 25740916 26699495
18:13:51 29088 .3545 7470840 25689519 31598178 3636175132 25723950 25732433 25740916 26699495
18:14:52 29786 .3630 7650248 25689519 31791790 3684771744 25723950 25732433 25740916 26699495
18:15:52 30478 .3715 7827440 25689519 31985901 3733493605 25723950 25732433 25740916 26699495
18:16:52 31168 .3799 8004776 25689519 32179513 3782090217 25723950 25732433 25740916 26699495
18:17:52 31854 .3882 8181232 25689519 32179513 3782090217 25723950 25732433 25740916 26699495
18:18:53 32540 .3966 8357448 25689519 32373624 3830812078 25723950 25732433 25740916 26699495
18:19:53 33239 .4051 8536848 25689519 32567735 3879533939 25723950 25732433 25740916 26699495
18:20:54 33938 .4136 8716280 25689519 32761347 3928130551 25723950 25732433 25740916 26699495
18:21:54 34629 .4220 8893816 25689519 32761347 3928130551 25723950 25732433 25740916 26699495
18:22:54 35325 .4305 9072616 25689519 32955458 3976852412 25723950 25732433 25740916 26699495
18:23:55 36009 .4389 9247792 25689519 33149070 4025449024 25723950 25732433 25740916 26699495
18:24:55 36706 .4474 9427176 25689519 33343181 4074170885 25723950 25732433 25740916 26699495
18:25:55 37393 .4557 9603984 25689519 33343181 4074170885 25723950 25732433 25740916 26699495
18:26:56 38082 .4641 9780480 25689519 33537292 4122892746 25723950 25732433 25740916 26699495
18:27:56 38777 .4726 9958784 25689519 33730904 4171489358 25723950 25732433 25740916 26699495
18:28:56 39464 .4810 10135552 25689519 33730904 4171489358 25723950 25732433 25740916 26699495
18:29:57 40156 .4894 10313392 25689519 33925015 4220211219 25723950 25732433 25740916 26699495
18:30:57 40844 .4978 10489848 25689519 34118627 4268807831 25723950 25732433 25740916 26699495
18:31:58 41386 .5044 10628600 25723950 34312738 22562396 25723950 25732433 25740916 26699495
18:32:58 42073 .5128 10805768 25723950 34312738 22562396 25723950 25732433 25740916 26699495
18:33:59 42752 .5211 10979680 25723950 34506849 71284257 34285792 34294774 34303257 26699495
18:34:59 38748 .4723 9951160 26699495 34700461 119880869 34285792 34294774 34303257 26699495
18:36:00 39429 .4806 10125920 26699495 34894572 168602730 34285792 34294774 34303257 26699495
18:37:00 40101 .4887 10299360 26699495 34894572 168602730 34285792 34294774 34303257 26699495
18:38:00 40785 .4971 10474640 26699495 35088184 217199342 34285792 34294774 34303257 26699495
18:39:01 41483 .5056 10653552 26699495 35282295 265921203 34285792 34294774 34303257 26699495
18:40:01 5950 .0725 1528160 34252359 35476406 314643064 34285792 34294774 34303257 35255848
18:41:01 6648 .0810 1707480 34252359 35476406 314643064 34285792 34294774 34303257 35255848
18:42:02 7362 .0897 1890664 34252359 35670018 363239676 34285792 34294774 34303257 35255848
18:43:02 8080 .0984 2075216 34252359 35864129 411961537 34285792 34294774 34303257 35255848
18:44:02 8774 .1069 2253432 34252359 36057741 460558149 34285792 34294774 34303257 35255848
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 19:06 ` Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:37 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
3 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-04 19:06 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Sun, May 3, 2015 at 7:49 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Restricting ourselves to selecting tables to vacuum using their
> relminmxid alone makes this patch small since autovacuum already works
> that way. We *could* introduce code that would be able to spread out
> the work of vacuuming tables that happen to have identical or very
> close relminmxid (say by introducing some non-determinism or doing
> something weird based on hashing table oids and the time to explicitly
> spread the start of processing over time, or <your idea here>), but I
> didn't want to propose anything too big/complicated/clever/stupid and
> I suspect that the relminmxid values will tend to diverge over time
> (but I could be wrong about that, if they all start at 1 and then move
> forward in lockstep over long periods of time then what I propose is
> not good enough... let's see if we can find out).
So, the problem of everything moving in lockstep is one we already
have. It's actually a serious operational problem for relfrozenxid,
because you might restore your database from pg_dump or similar and
every table will have a very similar relfrozenxid and so then the
anti-wraparound logic fires for all of them at the same time. There
might be cases where MXIDs behave the same way, although I would think
it would be less common.
Anyway, solving that problem would be nice (particularly for xmin!),
but we shouldn't get into that with relation to this bug fix. It's a
problem, but one that will probably take a good deal of work to solve,
and certainly not something we would back-patch.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 19:06 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-04 20:37 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-04 20:37 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Robert Haas wrote:
> Anyway, solving that problem would be nice (particularly for xmin!),
> but we shouldn't get into that with relation to this bug fix. It's a
> problem, but one that will probably take a good deal of work to solve,
> and certainly not something we would back-patch.
+1
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 20:59 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 21:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-05 03:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
3 siblings, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-04 20:59 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Robert Haas <robertmhaas@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
So I might have understood an earlier description of the proposed
solution all wrong, or this patch was designed without consideration to
that description. What I thought would happen is that all freeze ages
would get multiplied by some factor <= 1, depending on the space used up
by members. If members space usage is low enough, factor would remain
at 1 so things would behave as today. If members space usage is larger
than X, the factor decreases smoothly and this makes freeze_min_age and
freeze_max_age decrease smoothly as well, for all vacuums equally.
For instance, we could choose a method to compute X based on considering
that a full 2^32 storage area for members is enough to store one
vacuum_multixact_freeze_table_age cycle of multixacts. The default
value of this param is 150 million, and 2^32/150000000 = 28; so if your
average multixact size = 38, you would set the multiplier at 0.736 and
your effective freeze_table_age would become 110 million and effective
freeze_min_age would become 3.68 million.
As a secondary point, I find variable-names-as-documentation bad
practice. Please don't use a long name such as
max_multixact_age_to_avoid_member_wrap; code becomes unwieldy. A short
name such as safe_mxact_age preceded by a comment /* this variable is
the max that avoids member wrap */ seems more palatable; side-by-side
merges and all that! I don't think long function names are as
problematic (though the name of your new function is still a bit too
long).
Please note that 9.4 and earlier do not have ExecVacuum; the
determination of freeze ages is done partly in gram.y (yuck). Not sure
what will the patch look like in those branches.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 20:59 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-04 21:30 ` Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-04 21:30 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Robert Haas <robertmhaas@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Alvaro Herrera wrote:
> For instance, we could choose a method to compute X based on considering
> that a full 2^32 storage area for members is enough to store one
> vacuum_multixact_freeze_table_age cycle of multixacts. The default
> value of this param is 150 million, and 2^32/150000000 = 28; so if your
> average multixact size = 38, you would set the multiplier at 0.736 and
> your effective freeze_table_age would become 110 million and effective
> freeze_min_age would become 3.68 million.
Actually, apologies --- this is not what I was thinking at all. I got
distracted while I was writing the previous email. My thinking was that
the values would be at their normal defaults when the wraparound is
distant, and the multiplier would start to become slightly less than 1
as the counter moves towards wraparound; by the time we're at at an
emergency i.e. we reach max_freeze_age, the values naturally become zero
(or perhaps just before we reach max_freeze_age, the values were 50% of
their normal values, so the drop to zero is not as dramatic). Since
this is gradual, the behavior is not as jumpy as in the proposed patch.
Anyway this is in line with what Kevin is saying elsewhere: we shouldn't
just use the normal values all the time just up to the freeze_max_age
point; there should be some gradual ramp-up.
Perhaps we can combine this with the other idea of using a multiplier
connected to average size of multixact, if it doesn't become too
complicated, surprising, or both.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 20:59 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-05 03:56 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-05 04:11 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 113+ messages in thread
From: Amit Kapila @ 2015-05-05 03:56 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Robert Haas <robertmhaas@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, May 5, 2015 at 2:29 AM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
>
>
> Please note that 9.4 and earlier do not have ExecVacuum; the
> determination of freeze ages is done partly in gram.y (yuck). Not sure
> what will the patch look like in those branches.
>
One way to make fix back-patchable is to consider doing the changes
for Vacuum and AutoVacuum in one common path (vacuum_set_xid_limits())?
However, I think we might need to distinguish whether the call is from
Vacuum or AutoVacuum path.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 20:59 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-05 03:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
@ 2015-05-05 04:11 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-05 04:11 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Robert Haas <robertmhaas@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Amit Kapila wrote:
> On Tue, May 5, 2015 at 2:29 AM, Alvaro Herrera <alvherre@2ndquadrant.com>
> wrote:
> >
> >
> > Please note that 9.4 and earlier do not have ExecVacuum; the
> > determination of freeze ages is done partly in gram.y (yuck). Not sure
> > what will the patch look like in those branches.
>
> One way to make fix back-patchable is to consider doing the changes
> for Vacuum and AutoVacuum in one common path (vacuum_set_xid_limits())?
> However, I think we might need to distinguish whether the call is from
> Vacuum or AutoVacuum path.
I think it's easier if we just adjust the patch in older branches to
affect the code that now lives in ExecVacuum. Trying to make all
branches the same will probably make the whole thing more complicated,
for no real purpose.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 18:46 ` Robert Haas <robertmhaas@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-04 18:46 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Sat, May 2, 2015 at 2:16 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Here's a new version which sets up the multixact parameters in
> ExecVacuum for regular VACUUM commands just like it does for
> autovacuum if needed. When computing
> max_multixact_age_to_avoid_member_wrap for a manual vacuum, it uses
> lower constants, so that any manually scheduled vacuums get a chance
> to deal with some of this problem before autovacuum has to. Here are
> the arbitrary constants currently used: at 50% member address space
> usage, autovacuum starts wraparound scan of tables with the oldest
> active multixacts, and then younger ones as the usage increases, until
> at 75% usage it vacuums with multixact_freeze_table_age = 0; for
> manual VACUUM those numbers are halved so that it has a good head
> start.
I think the 75% threshold for reducing multxact_freeze_table_age to
zero is fine, but I don't agree with the 50% cutoff. The purpose of
autovacuum_multixact_freeze_max_age is to control the fraction of the
2^32-entry offset space that can be consumed before we begin viewing
the problem as urgent. We have a setting for that because it needs to
be tunable, and the default value for that setting is 400 million,
which is roughly 10% of the members space. That is a whole lot lower
than the 50% threshold you are proposing here. Moreover, it leaves
the user with no meaningful choice: if the 50% threshold consumes too
much disk space, or doesn't leave enough room before we hit the wall,
then the user is simply hosed. This is why I initially proposed that
the member-space-consumption-percentage at which we start derating
multixact_freeze_table_age should be based on
autovacuum_multixact_freeze_max_age/2^32. That way,
autovacuum_multixact_freeze_max_age controls not only how aggressively
we try to reclaim offset space but also how aggressively we try to
reclaim member space. The user can then tune the value, and the
default is the same in both cases.
I also think that halving the numbers for manual vacuums is arbitrary
and unprecedented. The thought process isn't bad, but an autovacuum
currently behaves in most respects like a manual vacuum, and I'm
reluctant to make those more different.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-02 11:22 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2 siblings, 1 reply; 113+ messages in thread
From: Amit Kapila @ 2015-05-02 11:22 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Thu, Apr 30, 2015 at 10:47 AM, Thomas Munro <
thomas.munro@enterprisedb.com> wrote:
>
> On Wed, Apr 29, 2015 at 11:41 PM, Amit Kapila <amit.kapila16@gmail.com>
wrote:
>
> > 3. currently there is some minimum limit of
autovacuum_multixact_freeze_age
> > (10000000)
> > which might not be honored by this calculation, so not sure if that can
> > impact the
> > system performance in some cases where it is currently working sane.
>
> The reason why we need to be able to set the effective freeze age
> below that minimum in cases of high member data consumption rates is
> that you could hit the new member space wraparound prevention error
> before you consume anywhere near that many multixact IDs. That
> minimum may well be entirely reasonable if the only thing you're
> worried about is multixact ID wraparound prevention.
>
> For example, my test program eats an average of 250 members per
> multixact ID when run with 500 sessions (each loop creates 500
> multixact IDs having 1, 2, 3, ..., 500 members). At that rate, you'll
> run out of addressable member space after 2^32 / 250 = 17,179,869
> multixact IDs. To prevent an error condition using only the existing
> multixact ID wraparound prevention machinery, we need to have an
> effective max table age (so that autovacuum wakes up and scans all
> tables) and min freeze age (so that it actually freezes the tuples)
> below that number. So we have to ignore the GUC minimum in this
> situation.
>
I understand that point, but I mentioned so that if there is some specific
reason for keeping the current minimum value, then we should evaluate
that we have not broken the same by not honouring the minimum value of
GUC. As far as I can see from code, there seems to be one place
(refer below code) where that value is used to calculate Warning limit for
multixacts and the current patch doesn't seem to have any impact on the
same.
SetMultiXactIdLimit()
{
..
multiWarnLimit = multiStopLimit - 10000000;
}
> ...
>
> Observations:
>
> 1. Sometimes the values don't change from minute to minute,
> presumably because there hasn't been a checkpoint to update
> pg_controldata on disk, but hopefully we can still see what's going on
> here despite the slight lag in the data.
>
Yeah and I think this means that there will no advancement for oldest
multixactid and deletion of files if the checkpoints are configured for
a timeout value. I think there is no harm in specifying this in document
if it is currently not specified.
> 2. We get to somewhere in the 73-75% SLRU used range before
> wraparound vacuums are triggered. We probably need to spread things
> out more that that.
>
> 3. When the autovacuum runs, it advances oldest_mxid by different
> amounts each time; that's because I'm using the adjusted freeze max
> age (the max age of a table before it gets a wraparound vacuum) as our
> freeze min age (the max age for individual tuples before they're
> frozen) here:
>
> @@ -1931,7 +1964,9 @@ do_autovacuum(void)
> {
> default_freeze_min_age = vacuum_freeze_min_age;
> default_freeze_table_age = vacuum_freeze_table_age;
> - default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
> + default_multixact_freeze_min_age =
> + Min(vacuum_multixact_freeze_min_age,
> + autovacuum_multixact_freeze_max_age_adjusted());
> default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
> }
>
> Without that change, autovacuum would trigger repeatedly as we got
> near 75% SLRU usage but not freeze anything, because
> default_multixact_freeze_min_age was higher than the age of any tuples
> (which had only made it to an age of around ~12 million; actually it's
> not exactly the tuple age per se... I don't fully understand the
> treatment of locker and updater multixact IDs in the vacuum code,
> HeapTupleSatisfiesVacuum and heap_freeze_tuple etc yet so I'm not sure
> exactly how that value translates into vacuum work, but I can see
> experimentally that a low multixact freeze min age is needed to get
> relminxmid moved forward).
>
> It's good that freeze table age ramps down so that the autovacuum
> launcher trigger point jumps around a bit and we spread the autovacuum
> launches over time, but it's not great that we finish up truncating
> different amounts of multixacts and associated SLRU each time. We
> could instead use a freeze min age of 0 to force freezing of *all*
> tuples if this is a member-space-wraparound-prevention vacuum (that
> is, if autovacuum_multixact_freeze_max_age !=
> autovacuum_multixact_freeze_max_age_adjusted()).
We already set vacuum_multixact_freeze_min_age to half of
autovacuum_multixact_freeze_max_age so that autovacuums to
prevent MultiXact wraparound won't occur too frequently as per below
code:
vacuum_set_xid_limits()
{
..
mxid_freezemin = Min(mxid_freezemin,
autovacuum_multixact_freeze_max_age / 2);
Assert(mxid_freezemin >= 0);
..
}
Now if we set it to zero, then I think it might lead to excessive
freezing and inturn more I/O without the actual need (more space
for multixact members)
>
> There is less to say about the results with an unpatched server: it
> drives in a straight line for a while, and then crashes into a wall
> (ie the new error preventing member wraparound), which I see you have
> also reproduced. It's used up all of the circular member space, but
> only has around 17 million multixacts so autovacuum can't help you
> (it's not even possible to set autovacuum_multixact_freeze_max_age
> below 100 million), so to get things moving again you need to manually
> VACUUM FREEZE all databases including template databases.
>
In my tests on setting vacuum multixact parameter
(vacuum_multixact_freeze_table_age and vacuum_multixact_freeze_min_age)
values to zero, it has successfuly finished the tests (no warning and I
could
see truncation of files in members directory) , so I think one might argue
that in many cases one could get the available space for members by
just setting appropriate values for vacuum_multixact_* params, but I feel
it is better to have some auto adjustment algorithm like this patch is
trying to do so that even if those values are not set appropriately, it can
avoid the wraparound error. I think the only thing we might need to be
cautious about is that new calculation should not make it worse (less
aggresive) in case of lower values for vacuum_multixact_* parameters.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
@ 2015-05-04 19:01 ` Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-04 19:01 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Sat, May 2, 2015 at 7:22 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>> 3. When the autovacuum runs, it advances oldest_mxid by different
>> amounts each time; that's because I'm using the adjusted freeze max
>> age (the max age of a table before it gets a wraparound vacuum) as our
>> freeze min age (the max age for individual tuples before they're
>> frozen) here:
>>
>> @@ -1931,7 +1964,9 @@ do_autovacuum(void)
>> {
>> default_freeze_min_age = vacuum_freeze_min_age;
>> default_freeze_table_age = vacuum_freeze_table_age;
>> - default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
>> + default_multixact_freeze_min_age =
>> + Min(vacuum_multixact_freeze_min_age,
>> + autovacuum_multixact_freeze_max_age_adjusted());
>> default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
>> }
>>
>> Without that change, autovacuum would trigger repeatedly as we got
>> near 75% SLRU usage but not freeze anything, because
>> default_multixact_freeze_min_age was higher than the age of any tuples
>> (which had only made it to an age of around ~12 million; actually it's
>> not exactly the tuple age per se... I don't fully understand the
>> treatment of locker and updater multixact IDs in the vacuum code,
>> HeapTupleSatisfiesVacuum and heap_freeze_tuple etc yet so I'm not sure
>> exactly how that value translates into vacuum work, but I can see
>> experimentally that a low multixact freeze min age is needed to get
>> relminxmid moved forward).
>>
>> It's good that freeze table age ramps down so that the autovacuum
>> launcher trigger point jumps around a bit and we spread the autovacuum
>> launches over time, but it's not great that we finish up truncating
>> different amounts of multixacts and associated SLRU each time. We
>> could instead use a freeze min age of 0 to force freezing of *all*
>> tuples if this is a member-space-wraparound-prevention vacuum (that
>> is, if autovacuum_multixact_freeze_max_age !=
>> autovacuum_multixact_freeze_max_age_adjusted()).
>
> We already set vacuum_multixact_freeze_min_age to half of
> autovacuum_multixact_freeze_max_age so that autovacuums to
> prevent MultiXact wraparound won't occur too frequently as per below
> code:
>
> vacuum_set_xid_limits()
> {
> ..
> mxid_freezemin = Min(mxid_freezemin,
>
> autovacuum_multixact_freeze_max_age / 2);
> Assert(mxid_freezemin >= 0);
> ..
> }
>
> Now if we set it to zero, then I think it might lead to excessive
> freezing and inturn more I/O without the actual need (more space
> for multixact members)
That point is certainly worthy of some consideration. Letting the
freeze xmin get set to half of the (effective)
autovacuum_multixact_freeze_age would certainly be more consistent
with what we do elsewhere. The policy trade-off is not as
straightforward as you are making it out to be, though:
1. Using a min freeze age of zero will result in half as many
full-table scans, because we'll advance relminmxid twice as far each
time.
2. But each one will freeze more stuff, some of which might have been
updated again before the next freeze pass, so we might do more
freezing in total.
So either policy might win, depending on whether you care more about
reducing reads (in which case you want a very low min freeze age) or
about reducing writes (in which case you want a higher min freeze
age).
All things being equal, I'd rather stick with the existing 50% policy
in the back-branches, rather than going to zero, but I'm not sure all
things are equal. It matters what difference the higher value makes.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-04 20:41 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-05-04 20:41 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; Amit Kapila <amit.kapila16@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas <robertmhaas@gmail.com> wrote:
> 1. Using a min freeze age of zero will result in half as many
> full-table scans, because we'll advance relminmxid twice as far
> each time.
>
> 2. But each one will freeze more stuff, some of which might have
> been updated again before the next freeze pass, so we might do
> more freezing in total.
>
> So either policy might win, depending on whether you care more
> about reducing reads (in which case you want a very low min
> freeze age) or about reducing writes (in which case you want a
> higher min freeze age).
>
> All things being equal, I'd rather stick with the existing 50%
> policy in the back-branches, rather than going to zero, but I'm
> not sure all things are equal. It matters what difference the
> higher value makes.
I really don't like the "honor the configured value of
vacuum_multixact_freeze_min_age until the members SLRU gets to 50%
of wraparound and then use zero" approach. It made a lot more
sense to me to honor the configured value to 25% and decrease it in
a linear fashion until it hit zero at 75%. It seems like maybe we
weren't aggressive enough in the dynamic adjustment of
autovacuum_multixact_freeze_max_age, but I'm not clear why fixing
that required the less gradual adjustment of the *_min_age setting.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-05-05 07:58 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-05 07:58 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Here's a new patch, with responses to several reviews.
On Tue, May 5, 2015 at 8:41 AM, Kevin Grittner <kgrittn@ymail.com> wrote:
> I really don't like the "honor the configured value of
> vacuum_multixact_freeze_min_age until the members SLRU gets to 50%
> of wraparound and then use zero" approach. It made a lot more
> sense to me to honor the configured value to 25% and decrease it in
> a linear fashion until it hit zero at 75%. It seems like maybe we
> weren't aggressive enough in the dynamic adjustment of
> autovacuum_multixact_freeze_max_age, but I'm not clear why fixing
> that required the less gradual adjustment of the *_min_age setting.
Ok, the new patch uses 25% as the safe threshold, and then scales
multixact_freeze_table_age down from the current number of active
multixacts (ie to select the minimum number of tables) progressively
to 0 (to select all tables) when you reach 75% usage. It also sets
multixact_freeze_min_age to half of the value it used for
multixact_table_age, so that reduces progressively too. But see my
response to Robert below for discussion (question) about how to make
safe threshold depend on autovacuum_multixact_freeze_max_age.
On Tue, May 5, 2015 at 8:37 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>> Anyway, solving that problem would be nice (particularly for xmin!),
>> but we shouldn't get into that with relation to this bug fix. It's a
>> problem, but one that will probably take a good deal of work to solve,
>> and certainly not something we would back-patch.
>
> +1
OK, not attempting to do anything about that. If your database has a
bunch of tables with the same relminmxid (for example after a recent
restore from pg_dump), you're going to get vacuums starting at the
same time. If they're more scrambled up, you'll get your vacuum work
spread out better, and that is just as it is for normal mxid
wraparound prevention so that is OK for the purposes of this patch.
On Tue, May 5, 2015 at 6:46 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> I think the 75% threshold for reducing multxact_freeze_table_age to
> zero is fine, but I don't agree with the 50% cutoff. The purpose of
> autovacuum_multixact_freeze_max_age is to control the fraction of the
> 2^32-entry offset space that can be consumed before we begin viewing
> the problem as urgent. We have a setting for that because it needs to
> be tunable, and the default value for that setting is 400 million,
> which is roughly 10% of the members space. That is a whole lot lower
> than the 50% threshold you are proposing here. Moreover, it leaves
> the user with no meaningful choice: if the 50% threshold consumes too
> much disk space, or doesn't leave enough room before we hit the wall,
> then the user is simply hosed. This is why I initially proposed that
> the member-space-consumption-percentage at which we start derating
> multixact_freeze_table_age should be based on
> autovacuum_multixact_freeze_max_age/2^32. That way,
> autovacuum_multixact_freeze_max_age controls not only how aggressively
> we try to reclaim offset space but also how aggressively we try to
> reclaim member space. The user can then tune the value, and the
> default is the same in both cases.
Ok, so if you have autovacuum_freeze_max_age = 400 million multixacts
before wraparound vacuum, which is ~10% of 2^32, we would interpret
that to mean 400 million multixacts OR ~10% * some_constant of member
space, in other worlds autovacuum_freeze_max_age * some_constant
members, whichever comes first. But what should some_constant be? If
it's 1, then we are only allowed 400 million members for our 400
million multixacts, which is not enough, if I am right in assuming
that multixacts (nearly?) always have 2 or more members: a setting of
400 million would trigger wraparound at 200 million multixacts (or
less) for *everyone* and trigger wraparound scans for some users as
soon as they upgrade. If it's 2, then anyone exceeding an average of
2 members would get their effective autovacuum_freeze_max_age lowered.
If it's 8, then people using the default max age of 400 million will
hit the 75% usage threshold that we have decided should trigger
freeze-everything-mode just as they hit the cutoff at which we start
doing anything, and for people who have raised the default value it
would be after (ahh, I might have the tests the wrong way around for
this scenario in MultiXactCheckMemberUsage() in the current patch...).
What do we know about expected multixact sizes in the wild, and what
sort of values people tend to set their
autovacuum_multixact_freeze_max_age to? Does anyone have a principled
suggestion for some_constant?
> I also think that halving the numbers for manual vacuums is arbitrary
> and unprecedented. The thought process isn't bad, but an autovacuum
> currently behaves in most respects like a manual vacuum, and I'm
> reluctant to make those more different.
Ok, removed.
On Tue, May 5, 2015 at 9:30 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> the values would be at their normal defaults when the wraparound is
> distant, and the multiplier would start to become slightly less than 1
> as the counter moves towards wraparound; by the time we're at at an
> emergency i.e. we reach max_freeze_age, the values naturally become zero
> (or perhaps just before we reach max_freeze_age, the values were 50% of
> their normal values, so the drop to zero is not as dramatic). Since
> this is gradual, the behavior is not as jumpy as in the proposed patch.
>
> Anyway this is in line with what Kevin is saying elsewhere: we shouldn't
> just use the normal values all the time just up to the freeze_max_age
> point; there should be some gradual ramp-up.
Ok, in the new patch multixact_freeze_min_age is ramped.
> Perhaps we can combine this with the other idea of using a multiplier
> connected to average size of multixact, if it doesn't become too
> complicated, surprising, or both.
What bothers me about this is that the average multixact size may
suddenly change, for example when new application code rolls out or a
nightly job runs, leading to a sudden change in member space
consumption, you might get in trouble by trying to be too clever with
predictions instead of just using something really simple based on
thresholds. But I might not be understanding what you meant...
On Mon, May 4, 2015 at 6:25 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> I think setting multixact_freeze_min_age to zero could be too aggresive
> for I/O. Yes with this you can get maximum benefit, but at cost of
> increased I/O. How would you justify setting it to zero as appropriate
> w.r.t increased I/O?
Changed back to ramped, see above.
> Isn't it better to use minimum to already computed value of
> multixact_freeze_max_age and max_multixact_age_to_avoid_member_wrap?
Ok, done.
On Tue, May 5, 2015 at 8:59 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> As a secondary point, I find variable-names-as-documentation bad
> practice. Please don't use a long name such as
> max_multixact_age_to_avoid_member_wrap; code becomes unwieldy. A short
> name such as safe_mxact_age preceded by a comment /* this variable is
> the max that avoids member wrap */ seems more palatable; side-by-side
> merges and all that! I don't think long function names are as
> problematic (though the name of your new function is still a bit too
> long).
I changed the function name to MultiXactCheckMemberUsage and moved
into multixact.c, and changed the variable name in various places to
safe_multixact_age. There were already a few comments explaining its
purpose.
> Please note that 9.4 and earlier do not have ExecVacuum; the
> determination of freeze ages is done partly in gram.y (yuck). Not sure
> what will the patch look like in those branches.
Autovacuum seems to parameterize vacuum via parser statements (!) so
why not just do the same if we detect that we arrived in vacuum via a
user command, and it wasn't a VACUUM FREEZE? In that case I think the
values arrive as -1. Like in the attached patch against 9.3 (not
tested).
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments: download all (2 files, .tar.gz)
memberswrap-autovacuum-6.patch (application/octet-stream, 10.5K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..cb877b1 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2578,6 +2578,97 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the address space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return -1 to indicate
+ * that no special action needs to be taken. This should always be the case
+ * for users who don't make use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between the safe and dangerous levels, we return the current number of
+ * active multixids scaled down linearly for higher usage fractions, so that
+ * vacuuming becomes more aggressive as the member SLRU grows, in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we define the safe member count to be
+ * half of the member address space, and the dangerous level to be
+ * three-quarters. These numbers are lowered for manual invocations of
+ * vacuum, to give scheduled vacuum commands a head start, so they have a
+ * chance to tackle member space usage problems before autovacuum needs to be
+ * invoked.
+ */
+int
+MultiXactCheckMemberUsage(void)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+ const MultiXactOffset safe_member_count = MaxMultiXactOffset / 4;
+ const MultiXactOffset dangerous_member_count = MaxMultiXactOffset -
+ (MaxMultiXactOffset / 4);
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members <= safe_member_count)
+ {
+ /* There is no danger of member space wrap currently. */
+ return -1;
+ }
+
+ if (members >= dangerous_member_count)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ /*
+ * Choose a cutoff age which is a fraction of the approximate current
+ * number of active multixacts. If we are using an amount of member
+ * address space near safe_member_count, we use a number close to the
+ * number of active multixacts, so that only tables with the oldest
+ * relminmxid values become candidates for wraparound vacuums. As we get
+ * closer to dangerous_member_count, we use a number closer to zero, so
+ * that more tables become candidates for wraparound vacuums.
+ */
+ fraction = (double) (members - safe_member_count) /
+ (double) (dangerous_member_count - safe_member_count);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..1bd2aa1 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -105,10 +105,24 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
+ {
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ params.multixact_freeze_table_age = safe_multixact_age;
+ params.multixact_freeze_min_age = safe_multixact_age / 2;
+ }
+ else
+ {
+ /* Use the default values. */
+ params.multixact_freeze_min_age = -1;
+ params.multixact_freeze_table_age = -1;
+ }
params.freeze_min_age = -1;
params.freeze_table_age = -1;
- params.multixact_freeze_min_age = -1;
- params.multixact_freeze_table_age = -1;
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..6441e94 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int safe_multixact_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1077,6 +1079,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int safe_multixact_age;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1121,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
+ multiForceLimit = recentMulti - Min(autovacuum_freeze_max_age,
+ safe_multixact_age);
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1889,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int safe_multixact_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1975,6 +1984,13 @@ do_autovacuum(void)
relScan = heap_beginscan_catalog(classRel, 0, NULL);
/*
+ * Check if member space usage is in danger of being exhausted, so we can
+ * pass the recommended cutoff age to relation_needs_vacanalyze and
+ * table_recheck_autovac.
+ */
+ safe_multixact_age = MultiXactCheckMemberUsage();
+
+ /*
* On the first pass, we collect main tables to vacuum, and also the main
* table relid to TOAST relid mapping.
*/
@@ -2001,6 +2017,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2146,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2253,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ safe_multixact_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2461,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int safe_multixact_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2508,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2571,18 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (safe_multixact_age >= 0)
+ {
+ multixact_freeze_table_age = Min(safe_multixact_age,
+ multixact_freeze_table_age);
+ multixact_freeze_min_age = Min(safe_multixact_age / 2,
+ multixact_freeze_min_age);
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2624,6 +2657,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2721,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (safe_multixact_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age, safe_multixact_age);
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..d86142d 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactCheckMemberUsage(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
memberswrap-autovacuum-6-REL9_3_STABLE.patch (application/octet-stream, 10.5K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 5532dc6..478e447 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2597,6 +2597,97 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the address space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return -1 to indicate
+ * that no special action needs to be taken. This should always be the case
+ * for users who don't make use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between the safe and dangerous levels, we return the current number of
+ * active multixids scaled down linearly for higher usage fractions, so that
+ * vacuuming becomes more aggressive as the member SLRU grows, in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
+ *
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we define the safe member count to be
+ * half of the member address space, and the dangerous level to be
+ * three-quarters. These numbers are lowered for manual invocations of
+ * vacuum, to give scheduled vacuum commands a head start, so they have a
+ * chance to tackle member space usage problems before autovacuum needs to be
+ * invoked.
+ */
+int
+MultiXactCheckMemberUsage(void)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+ const MultiXactOffset safe_member_count = MaxMultiXactOffset / 4;
+ const MultiXactOffset dangerous_member_count = MaxMultiXactOffset -
+ (MaxMultiXactOffset / 4);
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members <= safe_member_count)
+ {
+ /* There is no danger of member space wrap currently. */
+ return -1;
+ }
+
+ if (members >= dangerous_member_count)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ /*
+ * Choose a cutoff age which is a fraction of the approximate current
+ * number of active multixacts. If we are using an amount of member
+ * address space near safe_member_count, we use a number close to the
+ * number of active multixacts, so that only tables with the oldest
+ * relminmxid values become candidates for wraparound vacuums. As we get
+ * closer to dangerous_member_count, we use a number closer to zero, so
+ * that more tables become candidates for wraparound vacuums.
+ */
+ fraction = (double) (members - safe_member_count) /
+ (double) (dangerous_member_count - safe_member_count);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index ba3fbbd..2dbdcd8 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -112,6 +112,20 @@ vacuum(VacuumStmt *vacstmt, Oid relid, bool do_toast,
!(vacstmt->options & (VACOPT_FULL | VACOPT_FREEZE)));
Assert((vacstmt->options & VACOPT_ANALYZE) || vacstmt->va_cols == NIL);
+ if (isTopLevel && vacstmt->multixact_freeze_table_age == -1)
+ {
+ int safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
+ {
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ vacstmt->multixact_freeze_table_age = safe_multixact_age;
+ vacstmt->multixact_freeze_min_age = safe_multixact_age / 2;
+ }
+ }
+
stmttype = (vacstmt->options & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE";
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index f5b4704..937fa6c 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -302,11 +302,13 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int safe_multixact_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
AutoVacOpts2 *relopts2,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1107,6 +1109,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int safe_multixact_age;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1148,7 +1151,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
+ multiForceLimit = recentMulti - Min(autovacuum_freeze_max_age,
+ safe_multixact_age);
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1937,6 +1945,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int safe_multixact_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -2032,6 +2041,13 @@ do_autovacuum(void)
relScan = heap_beginscan(classRel, SnapshotNow, 0, NULL);
/*
+ * Check if member space usage is in danger of being exhausted, so we can
+ * pass the recommended cutoff age to relation_needs_vacanalyze and
+ * table_recheck_autovac.
+ */
+ safe_multixact_age = MultiXactCheckMemberUsage();
+
+ /*
* On the first pass, we collect main tables to vacuum, and also the main
* table relid to TOAST relid mapping.
*/
@@ -2059,6 +2075,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, relopts2, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2188,6 +2205,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, relopts2, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2278,7 +2296,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ safe_multixact_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2495,7 +2514,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int safe_multixact_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2542,6 +2562,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, avopts2, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2598,6 +2619,18 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts2->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (safe_multixact_age >= 0)
+ {
+ multixact_freeze_table_age = Min(safe_multixact_age,
+ multixact_freeze_table_age);
+ multixact_freeze_min_age = Min(safe_multixact_age / 2,
+ multixact_freeze_min_age);
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_dovacuum = dovacuum;
@@ -2670,6 +2703,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts2 *relopts2,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2733,6 +2767,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts2->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (safe_multixact_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age, safe_multixact_age);
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index e69a3d2..d4513d7 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactCheckMemberUsage(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-05 21:26 ` Robert Haas <robertmhaas@gmail.com>
2015-05-05 21:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-05 21:26 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Tue, May 5, 2015 at 3:58 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Ok, the new patch uses 25% as the safe threshold, and then scales
> multixact_freeze_table_age down from the current number of active
> multixacts (ie to select the minimum number of tables) progressively
> to 0 (to select all tables) when you reach 75% usage.
I definitely think that 25% is better than 50%. But see below.
> Ok, so if you have autovacuum_freeze_max_age = 400 million multixacts
> before wraparound vacuum, which is ~10% of 2^32, we would interpret
> that to mean 400 million multixacts OR ~10% * some_constant of member
> space, in other worlds autovacuum_freeze_max_age * some_constant
> members, whichever comes first. But what should some_constant be?
some_constant should be all the member space there is. So we trigger
autovac if we've used more than ~10% of the offsets OR more than ~10%
of the members. Why is autovacuum_multixact_freeze_max_age
configurable in the place? It's configurable so that you can set it
low enough that wraparound scans complete and advance the minmxid
before you hit the wall, but high enough to avoid excessive scanning.
The only problem is that it only lets you configure the amount of
headroom you need for offsets, not members. If you squint at what I'm
proposing the right way, it's essentially that that GUC should control
both of those things.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-05 21:46 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 22:36 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-06 01:43 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 01:53 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 3 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-05 21:46 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 9:26 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Tue, May 5, 2015 at 3:58 AM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>> Ok, so if you have autovacuum_freeze_max_age = 400 million multixacts
>> before wraparound vacuum, which is ~10% of 2^32, we would interpret
>> that to mean 400 million multixacts OR ~10% * some_constant of member
>> space, in other worlds autovacuum_freeze_max_age * some_constant
>> members, whichever comes first. But what should some_constant be?
>
> some_constant should be all the member space there is. So we trigger
> autovac if we've used more than ~10% of the offsets OR more than ~10%
> of the members. Why is autovacuum_multixact_freeze_max_age
> configurable in the place? It's configurable so that you can set it
> low enough that wraparound scans complete and advance the minmxid
> before you hit the wall, but high enough to avoid excessive scanning.
> The only problem is that it only lets you configure the amount of
> headroom you need for offsets, not members. If you squint at what I'm
> proposing the right way, it's essentially that that GUC should control
> both of those things.
But member space *always* grows at least twice as fast as offset space
(aka active multixact IDs), because multixacts always have at least 2
members (except in some rare cases IIUC), don't they? So if we do
what you just said, then we'll trigger wraparound vacuums twice as
soon as we do now for everybody, even people who don't have any
problem with member space management. We don't want this patch to
change anything for most people, let alone everyone. So I think that
some_constant should be at least 2, if we try to do it this way, in
other words if you set the GUC for 10% of offset space, we also start
triggering wraparounds at 20% of member space. The code in
MultiXactCheckMemberSpace would just say safe_member_count =
autovacum_multixact_freeze_max_age * 2, where 2 is some_constant (this
number is the average number of multixact members below which your
workload will be unaffected by the new autovac behaviour).
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-05 21:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-05 22:36 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-06 02:08 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2 siblings, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-05-05 22:36 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; Robert Haas <robertmhaas@gmail.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Thomas Munro <thomas.munro@enterprisedb.com> wrote:
> On Wed, May 6, 2015 at 9:26 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Tue, May 5, 2015 at 3:58 AM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>>> Ok, so if you have autovacuum_freeze_max_age = 400 million multixacts
>>> before wraparound vacuum, which is ~10% of 2^32, we would interpret
>>> that to mean 400 million multixacts OR ~10% * some_constant of member
>>> space, in other worlds autovacuum_freeze_max_age * some_constant
>>> members, whichever comes first. But what should some_constant be?
>>
>> some_constant should be all the member space there is. So we trigger
>> autovac if we've used more than ~10% of the offsets OR more than ~10%
>> of the members. Why is autovacuum_multixact_freeze_max_age
>> configurable in the place? It's configurable so that you can set it
>> low enough that wraparound scans complete and advance the minmxid
>> before you hit the wall, but high enough to avoid excessive scanning.
>> The only problem is that it only lets you configure the amount of
>> headroom you need for offsets, not members. If you squint at what I'm
>> proposing the right way, it's essentially that that GUC should control
>> both of those things.
>
> But member space *always* grows at least twice as fast as offset space
> (aka active multixact IDs), because multixacts always have at least 2
> members (except in some rare cases IIUC), don't they? So if we do
> what you just said, then we'll trigger wraparound vacuums twice as
> soon as we do now for everybody, even people who don't have any
> problem with member space management. We don't want this patch to
> change anything for most people, let alone everyone.
That, I think, is what has been driving this patch away from just
considering the *_multixact_* settings as applying to both the
members SLRU and the offsets SLRU; that would effectively simply
change the monitored resource from one to the other. (We would
probably want to actually use the max of the two, just to be safe,
but that offsets might never actually be the trigger.) As Thomas
says, that would be a big change for everyone, and not everyone
necessarily *wants* their existing settings to have new and
different meanings.
> So I think that
> some_constant should be at least 2, if we try to do it this way, in
> other words if you set the GUC for 10% of offset space, we also start
> triggering wraparounds at 20% of member space.
But what if they configure it to start at 80% (which I *have* seen
people do)?
The early patches were a heuristic to attempt to allow current
behavior for those not getting into trouble, and gradually ramp up
aggressiveness as needed to prevent hitting the hard ERROR that now
prevents wraparound. Perhaps, rather than reducing the threshold
gradually, as the members SLRU approaches wraparound we could
gradually shift from using offsets to members as the number we
compare the thresholds to. Up to 25% of maximum members, or if
offset is somehow larger, we just use offsets; else above 75%
maximum members we use members; else we use a weighted average
based on how far we are between 25% and 75%. It's kinda weird, but
I think it gives us a reasonable way to ramp up up vacuum
aggressiveness from what we currently do toward what Robert
proposed based on whether the workload is causing things to head
for trouble.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-05 21:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 22:36 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-05-06 02:08 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-06 02:08 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Tue, May 5, 2015 at 6:36 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
>> So I think that
>> some_constant should be at least 2, if we try to do it this way, in
>> other words if you set the GUC for 10% of offset space, we also start
>> triggering wraparounds at 20% of member space.
>
> But what if they configure it to start at 80% (which I *have* seen
> people do)?
I might be confused here, but the upper limit for
autovacuum_multixact_freeze_max_age is 2 billion, so I don't think
this can ever be higher than 50%. Well, 46.5%, really, since 2^32 > 4
billion. autovacuum_freeze_max_age is similarly limited.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-05 21:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-06 01:43 ` Thomas Munro <thomas.munro@enterprisedb.com>
2 siblings, 0 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-06 01:43 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 9:46 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Wed, May 6, 2015 at 9:26 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Tue, May 5, 2015 at 3:58 AM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>>> Ok, so if you have autovacuum_freeze_max_age = 400 million multixacts
>>> before wraparound vacuum, which is ~10% of 2^32, we would interpret
>>> that to mean 400 million multixacts OR ~10% * some_constant of member
>>> space, in other worlds autovacuum_freeze_max_age * some_constant
>>> members, whichever comes first. But what should some_constant be?
>>
>> some_constant should be all the member space there is. So we trigger
>> autovac if we've used more than ~10% of the offsets OR more than ~10%
>> of the members. Why is autovacuum_multixact_freeze_max_age
>> configurable in the place? It's configurable so that you can set it
>> low enough that wraparound scans complete and advance the minmxid
>> before you hit the wall, but high enough to avoid excessive scanning.
>> The only problem is that it only lets you configure the amount of
>> headroom you need for offsets, not members. If you squint at what I'm
>> proposing the right way, it's essentially that that GUC should control
>> both of those things.
>
> But member space *always* grows at least twice as fast as offset space
> (aka active multixact IDs), because multixacts always have at least 2
> members (except in some rare cases IIUC), don't they? So if we do
> what you just said, then we'll trigger wraparound vacuums twice as
> soon as we do now for everybody, even people who don't have any
> problem with member space management. We don't want this patch to
> change anything for most people, let alone everyone. So I think that
> some_constant should be at least 2, if we try to do it this way, in
> other words if you set the GUC for 10% of offset space, we also start
> triggering wraparounds at 20% of member space. The code in
> MultiXactCheckMemberSpace would just say safe_member_count =
> autovacum_multixact_freeze_max_age * 2, where 2 is some_constant (this
> number is the average number of multixact members below which your
> workload will be unaffected by the new autovac behaviour).
Here is a version of the patch that uses the GUC to control where
safe_member_count starts as you suggested. But it multiplies it by a
scaling factor that I'm calling avg_multixact_size_threshold. The key
point is this: if your average multixact size is below this number,
you will see no change in autovacuum behaviour from this patch,
because normal wraparound vacuums will occur before you ever exceed
safe_member_count, but if your average multixact size is above this
number, you'll see some extra wraparound vacuuming.
As for its value, I start the bidding at 3. Unless I misunderstood,
your proposal amounted to using a value of 1, but I think that is too
small, because surely *everyone's* average multixact size is above 1.
We don't want to change the autovacuum behaviour for everyone. I
figure the value should be a smallish number of at least 2, and I
speculate that that multixacts might have one of those kinds of
distributions where there are lots of 2s, a few 3s, hardly any 4s etc,
so that the average would be somewhere not far above 2. 3 seems to
fit that description. I could be completely wrong about that, but
even so, with the default GUC setting of 400 million, 3 gives you
(400000000 * 3) / 2^32 = ~28%, pretty close to the 25% that people
seemed to like when we were talking about a fixed constant. Higher
numbers could work but would make us less aggressive and increase the
wraparound risk, and 8 would definitely be too high, because then
safe_member_count crashes into dangerous_member_count with the default
GUC setting, so our ramping is effectively disabled giving us a panic
mode/cliff.
The new patch also tests the dangerous level *before* the safe level,
so that our 75% threshold is still triggered even if you set the GUC
insanely high so that safe_member_count finished up higher than
dangerous_member_count.
BTW I think you can estimate the average number of members per
multixact in a real database like this:
number of members = number of member segment files * 1636 * 32
over
number of multixacts = number of offsets segment files * 2048 * 32
Those numbers are from these macros with a default page size:
MULTIXACT_MEMBERS_PER_PAGE = 1636
MULTIXACT_OFFSETS_PER_PAGE = 2048
SLRU_PAGES_PER_SEGMENT = 32
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-autovacuum-7.patch (application/octet-stream, 11.3K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..7eb4a27 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2578,6 +2578,116 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the address space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return -1 to indicate
+ * that no special action needs to be taken. This should always be the case
+ * for users who don't make use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between the safe and dangerous levels, we return the current number of
+ * active multixids scaled down linearly for higher usage fractions, so that
+ * vacuuming becomes more aggressive as the member SLRU grows, in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
+ *
+ * The safe_member_count threshold is based on the
+ * autovacuum_multixact_freeze_max_age GUC and a scaling factor (see below).
+ *
+ * The dangerous_member_count threshold is arbitrarily set at 75% of member
+ * addressing space.
+ */
+int
+MultiXactCheckMemberUsage(void)
+{
+ /*
+ * The following constant controls the point at which the vacuum system
+ * interprets autovacuum_multixact_freeze_max_age GUC differently. If the
+ * average size of active multixacts is below this number, then this
+ * function should always return -1 so that no special action is taken to
+ * prevent member space wraparound, because autovacuum should trigger
+ * wraparound vacuums before the member space exceeds safe_member_count.
+ * If the average size of active multixacts is above this number, then
+ * member space usage should exceed safe_member_count before the usual
+ * multixact ID wraparound prevention, so this function will begin to
+ * return values that change the the behavior of autovacuum, so that
+ * wraparound vacuums start sooner to reduce member space usage.
+ */
+ const int avg_multixact_size_threshold = 3;
+
+ const MultiXactOffset dangerous_member_count = MaxMultiXactOffset -
+ (MaxMultiXactOffset / 4);
+
+ /* Avoid overflow if the GUC is set very high. */
+ const MultiXactOffset safe_member_count =
+ (autovacuum_multixact_freeze_max_age >= INT_MAX / avg_multixact_size_threshold
+ ? dangerous_member_count
+ : autovacuum_multixact_freeze_max_age * avg_multixact_size_threshold);
+
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members >= dangerous_member_count)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ if (members <= safe_member_count)
+ {
+ /* There is no danger of member space wrap currently. */
+ return -1;
+ }
+
+ /*
+ * Choose a cutoff age which is a fraction of the approximate current
+ * number of active multixacts. If we are using an amount of member
+ * address space near safe_member_count, we use a number close to the
+ * number of active multixacts, so that only tables with the oldest
+ * relminmxid values become candidates for wraparound vacuums. As we get
+ * closer to dangerous_member_count, we use a number closer to zero, so
+ * that more tables become candidates for wraparound vacuums.
+ */
+ fraction = (double) (members - safe_member_count) /
+ (double) (dangerous_member_count - safe_member_count);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..1bd2aa1 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -105,10 +105,24 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
+ {
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ params.multixact_freeze_table_age = safe_multixact_age;
+ params.multixact_freeze_min_age = safe_multixact_age / 2;
+ }
+ else
+ {
+ /* Use the default values. */
+ params.multixact_freeze_min_age = -1;
+ params.multixact_freeze_table_age = -1;
+ }
params.freeze_min_age = -1;
params.freeze_table_age = -1;
- params.multixact_freeze_min_age = -1;
- params.multixact_freeze_table_age = -1;
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..6441e94 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int safe_multixact_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1077,6 +1079,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int safe_multixact_age;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1121,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
+ multiForceLimit = recentMulti - Min(autovacuum_freeze_max_age,
+ safe_multixact_age);
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1889,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int safe_multixact_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1975,6 +1984,13 @@ do_autovacuum(void)
relScan = heap_beginscan_catalog(classRel, 0, NULL);
/*
+ * Check if member space usage is in danger of being exhausted, so we can
+ * pass the recommended cutoff age to relation_needs_vacanalyze and
+ * table_recheck_autovac.
+ */
+ safe_multixact_age = MultiXactCheckMemberUsage();
+
+ /*
* On the first pass, we collect main tables to vacuum, and also the main
* table relid to TOAST relid mapping.
*/
@@ -2001,6 +2017,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2146,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2253,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ safe_multixact_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2461,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int safe_multixact_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2508,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2571,18 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (safe_multixact_age >= 0)
+ {
+ multixact_freeze_table_age = Min(safe_multixact_age,
+ multixact_freeze_table_age);
+ multixact_freeze_min_age = Min(safe_multixact_age / 2,
+ multixact_freeze_min_age);
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2624,6 +2657,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2721,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (safe_multixact_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age, safe_multixact_age);
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..d86142d 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactCheckMemberUsage(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-05 21:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-06 01:53 ` Robert Haas <robertmhaas@gmail.com>
2 siblings, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-06 01:53 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Tue, May 5, 2015 at 5:46 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> But member space *always* grows at least twice as fast as offset space
> (aka active multixact IDs), because multixacts always have at least 2
> members (except in some rare cases IIUC), don't they?
Oh. *facepalm*
All right, so maybe the way you had it is best after all.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-06 02:29 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-06 02:29 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Tue, May 5, 2015 at 3:58 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Here's a new patch, with responses to several reviews.
Going back to this version...
+ * Based on the assumption that there is no reasonable way for an end user to
+ * configure the thresholds for this, we define the safe member count to be
+ * half of the member address space, and the dangerous level to be
but:
+ const MultiXactOffset safe_member_count = MaxMultiXactOffset / 4;
Those don't match. Also, we usually use #define rather than const for
constants. I suggest we do that here, too.
+ int safe_multixact_age = MultiXactCheckMemberUsage();
+ if (safe_multixact_age >= 0)
Project style is to leave a blank line between these, I think.
I think you need to update the comments for relation_needs_vacanalyze().
The documentation in section 23.1.5.1, "Multixacts and Wraparound",
also needs updating.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-06 10:26 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-06 10:26 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 2:29 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> + * Based on the assumption that there is no reasonable way for an end user to
> + * configure the thresholds for this, we define the safe member count to be
> + * half of the member address space, and the dangerous level to be
>
> but:
>
> + const MultiXactOffset safe_member_count = MaxMultiXactOffset / 4;
>
> Those don't match. [...]
Fixed/obsoleted in the attached patch. It has a dynamic
safe_member_count based on scaling the GUC as described in my earlier
email with the v7 patch; the behaviour with the default GUC value
works out to a similar safe_member_count value, but this way it can be
changed if needed, and we don't introduce any new GUCs. Also, since
the GUC used in determining safe_member_count is either
autovacuum_multixact_freeze_max_age or vacuum_multixact_freeze_max_age
depending on which kind of vacuum it is, that is now a parameter
passed into MultiXactCheckMemberUsage, so safe_member_count is no
longer a constant.
> [...] Also, we usually use #define rather than const for
> constants. I suggest we do that here, too.
Done for DANGEROUS_MEMBER_COUNT and AVG_MULTIXACT_SIZE_THRESHOLD which
are still constants.
> + int safe_multixact_age = MultiXactCheckMemberUsage();
> + if (safe_multixact_age >= 0)
>
> Project style is to leave a blank line between these, I think.
Done.
> I think you need to update the comments for relation_needs_vacanalyze().
Done.
> The documentation in section 23.1.5.1, "Multixacts and Wraparound",
> also needs updating.
Done. I also rewrote some of the commentary in
MultiXactCheckMemberUsage, to try to make the theory behind the ramp
up algorithm clearer.
I will do some more testing. Does anyone have any feedback on the
choice of value for AVG_MULTIXACT_SIZE_THRESHOLD, or real world data
on average multixact sizes, or see more general problems? The idea
here is that you should only see autovacuum behaviour change if it's
more than AVG_MULTIXACT_SIZE_THRESHOLD.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-autovacuum-8.patch (application/octet-stream, 14.8K) download
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 8764e00..ebb939a 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -628,6 +628,11 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
Like transaction IDs, multixact IDs are implemented as a
32-bit counter and corresponding storage, all of which requires
careful aging management, storage cleanup, and wraparound handling.
+ In addition to the multixact IDs, the storage area that holds the
+ transaction IDs included in each multixact must be managed. The number
+ of members in a multixact is variable and the storage used for members is
+ also addressed with a 32-bit index, so care must be taken to avoid running
+ out of addressable member storage space.
</para>
<para>
@@ -639,7 +644,11 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
<structname>pg_class</>.<structfield>relminmxid</> stores the oldest
possible multixact ID still appearing in any tuple of that table.
If this value is older than
- <xref linkend="guc-vacuum-multixact-freeze-table-age">, a whole-table
+ <xref linkend="guc-vacuum-multixact-freeze-table-age">, or if the amount
+ of used member storage space exceeds the amount that would be used by
+ that number of multixacts with an average of three members each and this
+ table has one of the older relminmxid values in the system, or if used
+ member storage exceeds 75% of addressable storage space, a whole-table
scan is forced. <function>mxid_age()</> can be used on
<structname>pg_class</>.<structfield>relminmxid</> to find its age.
</para>
@@ -655,8 +664,14 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
<para>
As a safety device, a whole-table vacuum scan will occur for any table
whose multixact-age is greater than
- <xref linkend="guc-autovacuum-multixact-freeze-max-age">.
- This will occur even if autovacuum is nominally disabled.
+ <xref linkend="guc-autovacuum-multixact-freeze-max-age">. Whole-table
+ vacuum scans will also occur progressively for all tables, starting with
+ those that have the oldest multixact-age, if the amount of used member
+ storage space exceeds the amount that would be used
+ by <xref linkend="guc-autovacuum-multixact-freeze-max-age"> multixacts
+ with an average of three members each, or exceeds 75% of addressable
+ storage space. These will occur even if autovacuum is nominally
+ disabled.
</para>
</sect3>
</sect2>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..09040e3 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2578,6 +2578,115 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Returns an instantaneous snapshot of the current number of active
+ * multixacts and the number of members in the members SLRU area.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * XXX: Could we store oldestMultiXactMemberOffset in shmem and
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Computes a multixact age that we can use to trigger earlier wraparound
+ * vacuums than usual, if special action is required to avoid impending
+ * exhaustion of the address space of multixact members (caused by large
+ * multixacts).
+ *
+ * If less than a "safe member count" is active, then we return -1 to indicate
+ * that no special action needs to be taken. This should always be the case
+ * for users who don't make use of large multixacts.
+ *
+ * If more than the "dangerous member count" is active, then we return a max
+ * freeze age of zero to trigger aggressive wraparound vacuuming.
+ *
+ * In between the safe and dangerous levels, we return the current number of
+ * active multixids scaled down linearly for higher usage fractions, so that
+ * vacuuming becomes more aggressive as the member SLRU grows, in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
+ *
+ * The safe member count threshold is based on the freeze_max_age passed in
+ * (either the autovacuum_multixact_freeze_max_age or
+ * vacuum_multixact_freeze_max_age GUC) and the scaling factor
+ * AVG_MULTIXACT_SIZE_THRESHOLD. If the average size of active multixids is
+ * below AVG_MULTIXACT_SIZE_THRESHOLD, then this function should always return
+ * -1 because autovacuum should trigger vacuums for multixact ID wraparound
+ * before the member space exceeds safe_member_count. If the average size of
+ * active multixacts is above this number, then member space usage should
+ * exceed safe_member_count before the usual multixact ID wraparound
+ * prevention, so this function will begin to return values that change the
+ * the behavior of vacuum and autovacuum to trigger vacuums sooner.
+ *
+ * The dangerous member count threshold is arbitrarily set at 75% of member
+ * addressing space.
+ */
+#define AVG_MULTIXACT_SIZE_THRESHOLD 3
+#define DANGEROUS_MEMBER_COUNT (MaxMultiXactOffset - (MaxMultiXactOffset / 4))
+int
+MultiXactCheckMemberUsage(int freeze_max_age)
+{
+ /* Avoid overflow if the passed in GUC is set very high. */
+ const MultiXactOffset safe_member_count =
+ (freeze_max_age >= INT_MAX / AVG_MULTIXACT_SIZE_THRESHOLD
+ ? DANGEROUS_MEMBER_COUNT
+ : freeze_max_age * AVG_MULTIXACT_SIZE_THRESHOLD);
+
+ MultiXactOffset members;
+ uint32 multixacts;
+ double fraction;
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ if (members >= DANGEROUS_MEMBER_COUNT)
+ {
+ /* We need a wraparound vacuum for all tables now. */
+ return 0;
+ }
+
+ if (members <= safe_member_count)
+ {
+ /* There is no danger of member space wrap currently. */
+ return -1;
+ }
+
+ /*
+ * At safe_member_count, we want to select the smallest possible fraction
+ * of tables to vacuum, and at DANGEROUS_MEMBER_COUNT, we want to select
+ * the largest fraction (all of them). The autovacuum code is based on
+ * selecting tables to vacuum by the age of their pg_class.relminmxid, and
+ * we know the age of the oldest multixact in the system, so that's the
+ * value we want to when members is near safe_member_count. It should
+ * hopefully select one table to work on. By gradually scaling that
+ * number down to zero as members moves towards DANGEROUS_MEMBER_COUNT, we
+ * select a greater fraction of tables to vacuum. How evenly this
+ * approach spreads vacuuming work depends on the distribution of tables'
+ * relminmxid values: the worst case is that they're all the same (like
+ * after a restored pg_dump), then we'll select them for vacuuming at the
+ * same time.
+ */
+ fraction = (double) (members - safe_member_count) /
+ (double) (DANGEROUS_MEMBER_COUNT - safe_member_count);
+ return (int) (multixacts * (1.0 - fraction));
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..a2199e8 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -105,10 +105,25 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int safe_multixact_age = MultiXactCheckMemberUsage(vacuum_multixact_freeze_table_age);
+
+ if (safe_multixact_age >= 0)
+ {
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ params.multixact_freeze_table_age = safe_multixact_age;
+ params.multixact_freeze_min_age = safe_multixact_age / 2;
+ }
+ else
+ {
+ /* Use the default values. */
+ params.multixact_freeze_min_age = -1;
+ params.multixact_freeze_table_age = -1;
+ }
params.freeze_min_age = -1;
params.freeze_table_age = -1;
- params.multixact_freeze_min_age = -1;
- params.multixact_freeze_table_age = -1;
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..47b58fd 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int safe_multixact_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1077,6 +1079,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int safe_multixact_age;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1121,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ safe_multixact_age = MultiXactCheckMemberUsage(autovacuum_multixact_freeze_max_age);
+ if (safe_multixact_age >= 0)
+ multiForceLimit = recentMulti - Min(autovacuum_freeze_max_age,
+ safe_multixact_age);
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1889,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int safe_multixact_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1975,6 +1984,13 @@ do_autovacuum(void)
relScan = heap_beginscan_catalog(classRel, 0, NULL);
/*
+ * Check if member space usage is in danger of being exhausted, so we can
+ * pass the recommended cutoff age to relation_needs_vacanalyze and
+ * table_recheck_autovac.
+ */
+ safe_multixact_age = MultiXactCheckMemberUsage(autovacuum_multixact_freeze_max_age);
+
+ /*
* On the first pass, we collect main tables to vacuum, and also the main
* table relid to TOAST relid mapping.
*/
@@ -2001,6 +2017,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2146,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2253,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ safe_multixact_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2461,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int safe_multixact_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2508,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ safe_multixact_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2571,18 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (safe_multixact_age >= 0)
+ {
+ multixact_freeze_table_age = Min(safe_multixact_age,
+ multixact_freeze_table_age);
+ multixact_freeze_min_age = Min(safe_multixact_age / 2,
+ multixact_freeze_min_age);
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2606,8 +2639,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
* analyze. This is asymmetric to the VACUUM case.
*
* We also force vacuum if the table's relfrozenxid is more than freeze_max_age
- * transactions back, and if its relminmxid is more than
- * multixact_freeze_max_age multixacts back.
+ * transactions back, or if its relminmxid is more than
+ * multixact_freeze_max_age or safe_multixact_age multixacts back.
*
* A table whose autovacuum_enabled option is false is
* automatically skipped (unless we have to vacuum it due to freeze_max_age).
@@ -2624,6 +2657,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int safe_multixact_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2721,10 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if we are running out of member address space. */
+ if (safe_multixact_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age, safe_multixact_age);
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..55a9f6c 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactCheckMemberUsage(int freze_max_age);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-06 10:45 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-06 10:45 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 6:26 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Wed, May 6, 2015 at 2:29 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> + * Based on the assumption that there is no reasonable way for an end user to
>> + * configure the thresholds for this, we define the safe member count to be
>> + * half of the member address space, and the dangerous level to be
>>
>> but:
>>
>> + const MultiXactOffset safe_member_count = MaxMultiXactOffset / 4;
>>
>> Those don't match. [...]
>
> Fixed/obsoleted in the attached patch. It has a dynamic
> safe_member_count based on scaling the GUC as described in my earlier
> email with the v7 patch; the behaviour with the default GUC value
> works out to a similar safe_member_count value, but this way it can be
> changed if needed, and we don't introduce any new GUCs. Also, since
> the GUC used in determining safe_member_count is either
> autovacuum_multixact_freeze_max_age or vacuum_multixact_freeze_max_age
> depending on which kind of vacuum it is, that is now a parameter
> passed into MultiXactCheckMemberUsage, so safe_member_count is no
> longer a constant.
To be honest, now that you've pointed out that the fraction of the
multixact members space that is in use will always be larger,
generally much larger, than the fraction of the offset space that is
in use, I've kind of lost all enthusiasm for making the
safe_member_count stuff dependent on
autovacuum_multixact_freeze_max_age. I'm inclined to go back to 25%,
the way you had it before.
We could think about adding a new GUC in master, but I'm actually
leaning toward the view that we should just hard-code 25% for now and
consider revising it later if that proves inadequate.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-06 13:32 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 20:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 3 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-06 13:32 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 6:45 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> To be honest, now that you've pointed out that the fraction of the
> multixact members space that is in use will always be larger,
> generally much larger, than the fraction of the offset space that is
> in use, I've kind of lost all enthusiasm for making the
> safe_member_count stuff dependent on
> autovacuum_multixact_freeze_max_age. I'm inclined to go back to 25%,
> the way you had it before.
>
> We could think about adding a new GUC in master, but I'm actually
> leaning toward the view that we should just hard-code 25% for now and
> consider revising it later if that proves inadequate.
So here's a new patch, based on your latest version, which looks
reasonably committable to me. I made a lot of revisions to the
comments. I changed some variable and function names, too. I also
reworked the function that determines the accelerated freeze threshold
because I was afraid that the integer return value might not be large
enough to accommodate the uint32 result of the derating calculation,
which would then turn negative. The new logic is also, I believe,
less vulnerable to floating-point roundoff dangers. And I tightened
up the documentation.
Some residual concerns:
1. Should we be installing one or more GUCs to control this behavior?
I've gone back to hard-coding things so that at 25% we start
triggering autovacuum and by 75% we zero out the freeze ages, because
the logic you proposed in your last version looks insanely complicated
to me. (I do realize that I suggested the approach, but that was
before I realized the full complexity of the problem.) I now think
that if we want to make this tunable, we need to create and expose
GUCs for it. I'm hoping we can get by without that, but I'm not sure.
2. Doesn't the code that sets MultiXactState->multiVacLimit also need
to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
similar logic? Otherwise, a user with autovacuum=off won't get
emergency autovacuums for member exhaustion, even though they will get
them for offset exhaustion.
Despite those concerns I think we're headed in the right direction here.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
multixact-av.patch (binary/octet-stream, 13.3K) download
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 8764e00..dcd9b78 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -628,6 +628,9 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
Like transaction IDs, multixact IDs are implemented as a
32-bit counter and corresponding storage, all of which requires
careful aging management, storage cleanup, and wraparound handling.
+ There is a separate storage area which holds the list of members in
+ each multixact, which also uses a 32-bit counter and which must also
+ be managed.
</para>
<para>
@@ -655,8 +658,11 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
<para>
As a safety device, a whole-table vacuum scan will occur for any table
whose multixact-age is greater than
- <xref linkend="guc-autovacuum-multixact-freeze-max-age">.
- This will occur even if autovacuum is nominally disabled.
+ <xref linkend="guc-autovacuum-multixact-freeze-max-age">. Whole-table
+ vacuum scans will also occur progressively for all tables, starting with
+ those that have the oldest multixact-age, if the amount of used member
+ storage space exceeds the amount 25% of the addressible storage space.
+ These will occur even if autovacuum is nominally disabled.
</para>
</sect3>
</sect2>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..d3319ec 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -168,6 +168,11 @@
(MXOffsetToFlagsOffset(xid) + MULTIXACT_FLAGBYTES_PER_GROUP + \
((xid) % MULTIXACT_MEMBERS_PER_MEMBERGROUP) * sizeof(TransactionId))
+/* Multixact members wraparound thresholds. */
+#define MULTIXACT_MEMBER_SAFE_THRESHOLD (MaxMultiXactOffset / 4)
+#define MULTIXACT_MEMBER_DANGER_THRESHOLD \
+ (MaxMultiXactOffset - MaxMultiXactOffset / 4)
+
/*
* Links to shared-memory data structures for MultiXact control
@@ -2578,6 +2583,87 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Determine how many multixacts, and how many multixact members, currently
+ * exist.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Multixact members can be removed once the multixacts that refer to them
+ * are older than every datminxmid. autovacuum_multixact_freeze_max_age and
+ * vacuum_multixact_freeze_table_age work together to make sure we never have
+ * too many multixacts; we hope that, at least under normal circumstances,
+ * this will also be sufficient to keep us from using too many offsets.
+ * However, if the average multixact has many members, we might exhaust the
+ * members space while still using few enough members that these limits fail
+ * to trigger full table scans for relminmxid advancement. At that point,
+ * we'd have no choice but to start failing multixact-creating operations
+ * with an error.
+ *
+ * To prevent that, if more than a threshold portion of the members space is
+ * used, we effectively reduce autovacuum_multixact_freeze_max_age and
+ * vacuum_multixact_freeze_table_age to a value just less than the number of
+ * multixacts in use. We hope that this will quickly trigger autovacuuming on
+ * the table or tables with the oldest relminmxid, thus allowing datminmxid
+ * values to advance and removing some members.
+ *
+ * As the fraction of the member space currently in use grows, we become
+ * more aggressive in clamping these values, so that autovacuum will begin
+ * working on more and more tables, and any manual vacuums the user issues
+ * will also become more aggressive. When it gets high enough, we assume
+ * the situation is desperate and treat both values as zero, essentially
+ * freezing every possible multixact.
+ *
+ * It's possible that these thresholds should be user-tunable, but for now
+ * we keep it simple.
+ */
+int
+MultiXactMemberFreezeThreshold(void)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ uint32 victim_multixacts;
+ double fraction;
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ /* If member space utilization is low, no special action is required. */
+ if (members <= MULTIXACT_MEMBER_SAFE_THRESHOLD)
+ return -1;
+
+ /*
+ * Compute a target for relminmxid advancement. The number of multixacts
+ * we try to eliminate from the system is based on how far we are past
+ * MULTIXACT_MEMBER_SAFE_THRESHOLD.
+ */
+ fraction = (double) (members - MULTIXACT_MEMBER_SAFE_THRESHOLD) /
+ (MULTIXACT_MEMBER_DANGER_THRESHOLD - MULTIXACT_MEMBER_SAFE_THRESHOLD);
+ victim_multixacts = multixacts * fraction;
+
+ /* fraction could be > 1.0, but lowest possible freeze age is zero */
+ if (victim_multixacts > multixacts)
+ return 0;
+ return multixacts - victim_multixacts;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..0b5ab40 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -92,10 +92,7 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
Assert((vacstmt->options & VACOPT_ANALYZE) || vacstmt->va_cols == NIL);
Assert(!(vacstmt->options & VACOPT_SKIPTOAST));
- /*
- * All freeze ages are zero if the FREEZE option is given; otherwise pass
- * them as -1 which means to use the default values.
- */
+ /* All freeze ages are zero if the FREEZE option is given. */
if (vacstmt->options & VACOPT_FREEZE)
{
params.freeze_min_age = 0;
@@ -105,10 +102,26 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int multixact_member_max_age;
+
+ /* Use defaults. */
params.freeze_min_age = -1;
params.freeze_table_age = -1;
params.multixact_freeze_min_age = -1;
params.multixact_freeze_table_age = -1;
+
+ /*
+ * Override the multixact freeze settings if we're using too much
+ * member address space. It's a bit of kludge to do this here,
+ * but if we pushed it down into vacuum(), autovacuum workers would
+ * repeat this calculation for every table.
+ */
+ multixact_member_max_age = MultiXactMemberFreezeThreshold();
+ if (multixact_member_max_age >= 0)
+ {
+ params.multixact_freeze_table_age = multixact_member_max_age;
+ params.multixact_freeze_min_age = multixact_member_max_age / 2;
+ }
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..db73886 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int multixact_member_max_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_member_max_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1077,6 +1079,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int multixact_member_max_age;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1121,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multixact_member_max_age = MultiXactMemberFreezeThreshold();
+ if (multixact_member_max_age >= 0)
+ multiForceLimit = recentMulti - Min(autovacuum_freeze_max_age,
+ multixact_member_max_age);
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1889,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int multixact_member_max_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1959,6 +1968,12 @@ do_autovacuum(void)
HASH_ELEM | HASH_BLOBS);
/*
+ * Determine whether we need to freeze multixacts more aggressively due
+ * to high multixact member utilization.
+ */
+ multixact_member_max_age = MultiXactMemberFreezeThreshold();
+
+ /*
* Scan pg_class to determine which tables to vacuum.
*
* We do this in two passes: on the first one we collect the list of plain
@@ -2001,6 +2016,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ multixact_member_max_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2145,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ multixact_member_max_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2252,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ multixact_member_max_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2460,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int multixact_member_max_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2507,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ multixact_member_max_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2570,18 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we're using too much
+ * member address space.
+ */
+ if (multixact_member_max_age >= 0)
+ {
+ multixact_freeze_table_age = Min(multixact_member_max_age,
+ multixact_freeze_table_age);
+ multixact_freeze_min_age = Min(multixact_member_max_age / 2,
+ multixact_freeze_min_age);
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2606,8 +2638,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
* analyze. This is asymmetric to the VACUUM case.
*
* We also force vacuum if the table's relfrozenxid is more than freeze_max_age
- * transactions back, and if its relminmxid is more than
- * multixact_freeze_max_age multixacts back.
+ * transactions back, or if its relminmxid is more than
+ * multixact_freeze_max_age or multixact_member_max_age multixacts back.
*
* A table whose autovacuum_enabled option is false is
* automatically skipped (unless we have to vacuum it due to freeze_max_age).
@@ -2624,6 +2656,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_member_max_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2720,11 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if too much multixact member space is in use. */
+ if (multixact_member_max_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age,
+ multixact_member_max_age);
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..9353289 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactMemberFreezeThreshold(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-06 14:17 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-06 14:17 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
I haven't read your patch, but I wonder if we should decrease the
default value of multixact_freeze_table_age (currently 150 million).
The freeze_min_age is 5 million; if freeze_table_age were a lot lower,
the problem would be less pronounced.
Additionally, I will backpatch commit 27846f02c176. The average size of
multixacts decreases with that fix in many common cases, which greatly
reduces the need for any of this in the first place.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-06 14:34 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:15 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2 siblings, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-06 14:34 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas wrote:
> So here's a new patch, based on your latest version, which looks
> reasonably committable to me.
I think this code should also reduce the multixact_freeze_min_age value
at the same time as multixact_freeze_table_age. If the table age is
reduced but freeze_min_age remains high, old multixacts might still
remain in the table. The default value for freeze min age is 5 million,
but users may change it. Perhaps freeze min age should be set to
Min(modified freeze table age, freeze min age) so that old multixacts
are effectively frozen whenever a full table scan requested.
> 1. Should we be installing one or more GUCs to control this behavior?
> I've gone back to hard-coding things so that at 25% we start
> triggering autovacuum and by 75% we zero out the freeze ages, because
> the logic you proposed in your last version looks insanely complicated
> to me. (I do realize that I suggested the approach, but that was
> before I realized the full complexity of the problem.) I now think
> that if we want to make this tunable, we need to create and expose
> GUCs for it. I'm hoping we can get by without that, but I'm not sure.
I think things are complicated enough; I vote for no additional GUCs at
this point.
> 2. Doesn't the code that sets MultiXactState->multiVacLimit also need
> to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
> similar logic? Otherwise, a user with autovacuum=off won't get
> emergency autovacuums for member exhaustion, even though they will get
> them for offset exhaustion.
Yeah, it looks like it does.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-06 16:15 ` Kevin Grittner <kgrittn@ymail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Kevin Grittner @ 2015-05-06 16:15 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>> So here's a new patch, based on your latest version, which looks
>> reasonably committable to me.
>
> I think this code should also reduce the multixact_freeze_min_age value
> at the same time as multixact_freeze_table_age. If the table age is
> reduced but freeze_min_age remains high, old multixacts might still
> remain in the table. The default value for freeze min age is 5 million,
> but users may change it. Perhaps freeze min age should be set to
> Min(modified freeze table age, freeze min age) so that old multixacts
> are effectively frozen whenever a full table scan requested.
I would rather see min age reduced proportionally to table age, or
at least ensure that min age is some percentage below table age.
>> 1. Should we be installing one or more GUCs to control this behavior?
>> I've gone back to hard-coding things so that at 25% we start
>> triggering autovacuum and by 75% we zero out the freeze ages, because
>> the logic you proposed in your last version looks insanely complicated
>> to me. (I do realize that I suggested the approach, but that was
>> before I realized the full complexity of the problem.) I now think
>> that if we want to make this tunable, we need to create and expose
>> GUCs for it. I'm hoping we can get by without that, but I'm not sure.
>
> I think things are complicated enough; I vote for no additional GUCs at
> this point.
+1
For one thing, we should try to have something we can back-patch,
and new GUCs in a minor release seems like something to avoid, if
possible. For another thing, we've tended not to put in GUCs if
there is no reasonable way for a user to determine a good value,
and that seems to be the case here.
>> 2. Doesn't the code that sets MultiXactState->multiVacLimit also need
>> to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
>> similar logic? Otherwise, a user with autovacuum=off won't get
>> emergency autovacuums for member exhaustion, even though they will get
>> them for offset exhaustion.
>
> Yeah, it looks like it does.
+1
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-06 16:23 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-06 16:23 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 10:34 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
>> So here's a new patch, based on your latest version, which looks
>> reasonably committable to me.
>
> I think this code should also reduce the multixact_freeze_min_age value
> at the same time as multixact_freeze_table_age.
I think it does that. It sets the min age to half the value it sets
for the table age, which I think is consistent with what we do
elsewhere.
>> 1. Should we be installing one or more GUCs to control this behavior?
>> I've gone back to hard-coding things so that at 25% we start
>> triggering autovacuum and by 75% we zero out the freeze ages, because
>> the logic you proposed in your last version looks insanely complicated
>> to me. (I do realize that I suggested the approach, but that was
>> before I realized the full complexity of the problem.) I now think
>> that if we want to make this tunable, we need to create and expose
>> GUCs for it. I'm hoping we can get by without that, but I'm not sure.
>
> I think things are complicated enough; I vote for no additional GUCs at
> this point.
That's fine with me for now.
>> 2. Doesn't the code that sets MultiXactState->multiVacLimit also need
>> to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
>> similar logic? Otherwise, a user with autovacuum=off won't get
>> emergency autovacuums for member exhaustion, even though they will get
>> them for offset exhaustion.
>
> Yeah, it looks like it does.
OK, I'm not clear how to do that correctly, exactly, but hopefully one
of us can figure that out.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 01:48 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-07 01:48 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 4:23 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, May 6, 2015 at 10:34 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>> 2. Doesn't the code that sets MultiXactState->multiVacLimit also need
>>> to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
>>> similar logic? Otherwise, a user with autovacuum=off won't get
>>> emergency autovacuums for member exhaustion, even though they will get
>>> them for offset exhaustion.
>>
>> Yeah, it looks like it does.
>
> OK, I'm not clear how to do that correctly, exactly, but hopefully one
> of us can figure that out.
MultiXactState->multiVacLimit holds the multixact IDs at which an age
thresholds will be crossed, so that GetNewMultiXactId can check it
cheaply. But we can't predict the future multixact IDs at which our
member usage threshold will be crossed. We could try to estimate it
based on past multixact sizes, but (as I think we already covered
somewhere else) we shouldn't be trying to do that because it wouldn't
handle the situation where your member space consumption rate suddenly
went up, among other problems.
How about this: we add oldestOffset to MultiXactState, to be set by
DetermineSafeOldestOffset, and then at the place where
GetNewMultiXactId checks if (!MultiXactIdPrecedes(result,
MultiXactState->multiVacLimit) it could also check whether (nextOffset
- MultiXactState->oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD).
ReadMultiXactCounts should also use the oldestOffset value directly
from shmem instead of calling find_multixact_start.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-07 02:44 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-07 02:44 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On May 6, 2015, at 9:48 PM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>> On Thu, May 7, 2015 at 4:23 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Wed, May 6, 2015 at 10:34 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>>> 2. Doesn't the code that sets MultiXactState->multiVacLimit also need
>>>> to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
>>>> similar logic? Otherwise, a user with autovacuum=off won't get
>>>> emergency autovacuums for member exhaustion, even though they will get
>>>> them for offset exhaustion.
>>>
>>> Yeah, it looks like it does.
>>
>> OK, I'm not clear how to do that correctly, exactly, but hopefully one
>> of us can figure that out.
>
> MultiXactState->multiVacLimit holds the multixact IDs at which an age
> thresholds will be crossed, so that GetNewMultiXactId can check it
> cheaply. But we can't predict the future multixact IDs at which our
> member usage threshold will be crossed. We could try to estimate it
> based on past multixact sizes, but (as I think we already covered
> somewhere else) we shouldn't be trying to do that because it wouldn't
> handle the situation where your member space consumption rate suddenly
> went up, among other problems.
>
> How about this: we add oldestOffset to MultiXactState, to be set by
> DetermineSafeOldestOffset, and then at the place where
> GetNewMultiXactId checks if (!MultiXactIdPrecedes(result,
> MultiXactState->multiVacLimit) it could also check whether (nextOffset
> - MultiXactState->oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD).
> ReadMultiXactCounts should also use the oldestOffset value directly
> from shmem instead of calling find_multixact_start.
That sounds pretty good.
...Robert
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 04:23 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 14:02 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-07 04:23 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 2:44 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On May 6, 2015, at 9:48 PM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>>> On Thu, May 7, 2015 at 4:23 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>>> On Wed, May 6, 2015 at 10:34 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>>>> 2. Doesn't the code that sets MultiXactState->multiVacLimit also need
>>>>> to use what I'm now calling MultiXactMemberFreezeThreshold() - or some
>>>>> similar logic? Otherwise, a user with autovacuum=off won't get
>>>>> emergency autovacuums for member exhaustion, even though they will get
>>>>> them for offset exhaustion.
>>>>
>>>> Yeah, it looks like it does.
>>>
>>> OK, I'm not clear how to do that correctly, exactly, but hopefully one
>>> of us can figure that out.
>>
>> MultiXactState->multiVacLimit holds the multixact IDs at which an age
>> thresholds will be crossed, so that GetNewMultiXactId can check it
>> cheaply. But we can't predict the future multixact IDs at which our
>> member usage threshold will be crossed. We could try to estimate it
>> based on past multixact sizes, but (as I think we already covered
>> somewhere else) we shouldn't be trying to do that because it wouldn't
>> handle the situation where your member space consumption rate suddenly
>> went up, among other problems.
>>
>> How about this: we add oldestOffset to MultiXactState, to be set by
>> DetermineSafeOldestOffset, and then at the place where
>> GetNewMultiXactId checks if (!MultiXactIdPrecedes(result,
>> MultiXactState->multiVacLimit) it could also check whether (nextOffset
>> - MultiXactState->oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD).
>> ReadMultiXactCounts should also use the oldestOffset value directly
>> from shmem instead of calling find_multixact_start.
>
> That sounds pretty good.
See attached patch, based on your multixact-av.patch. With autovacuum
set to off, it vacuums as expected. I wonder if
DetermineSafeOdlestOffset is being called in all the right places to
guarantee that the state is initialised.
This patch will change it anyway, but I noticed that oldestOffset's
computation to find the start of the segment seems wrong in master, I
think it should be like this, no?
@@ -2495,7 +2495,7 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
*/
oldestOffset = find_multixact_start(oldestMXact);
/* move back to start of the corresponding segment */
- oldestOffset -= oldestOffset / MULTIXACT_MEMBERS_PER_PAGE *
SLRU_PAGES_PER_SEGMENT;
+ oldestOffset -= oldestOffset % (MULTIXACT_MEMBERS_PER_PAGE *
SLRU_PAGES_PER_SEGMENT);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
/* always leave one segment before the wraparound point */
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-autovacuum-9.patch (application/octet-stream, 15.3K) download
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 8764e00..dcd9b78 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -628,6 +628,9 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
Like transaction IDs, multixact IDs are implemented as a
32-bit counter and corresponding storage, all of which requires
careful aging management, storage cleanup, and wraparound handling.
+ There is a separate storage area which holds the list of members in
+ each multixact, which also uses a 32-bit counter and which must also
+ be managed.
</para>
<para>
@@ -655,8 +658,11 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
<para>
As a safety device, a whole-table vacuum scan will occur for any table
whose multixact-age is greater than
- <xref linkend="guc-autovacuum-multixact-freeze-max-age">.
- This will occur even if autovacuum is nominally disabled.
+ <xref linkend="guc-autovacuum-multixact-freeze-max-age">. Whole-table
+ vacuum scans will also occur progressively for all tables, starting with
+ those that have the oldest multixact-age, if the amount of used member
+ storage space exceeds the amount 25% of the addressible storage space.
+ These will occur even if autovacuum is nominally disabled.
</para>
</sect3>
</sect2>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 928f9fe..5ce841d 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -168,6 +168,11 @@
(MXOffsetToFlagsOffset(xid) + MULTIXACT_FLAGBYTES_PER_GROUP + \
((xid) % MULTIXACT_MEMBERS_PER_MEMBERGROUP) * sizeof(TransactionId))
+/* Multixact members wraparound thresholds. */
+#define MULTIXACT_MEMBER_SAFE_THRESHOLD (MaxMultiXactOffset / 4)
+#define MULTIXACT_MEMBER_DANGER_THRESHOLD \
+ (MaxMultiXactOffset - MaxMultiXactOffset / 4)
+
/*
* Links to shared-memory data structures for MultiXact control
@@ -199,6 +204,7 @@ typedef struct MultiXactStateData
*/
MultiXactId oldestMultiXactId;
Oid oldestMultiXactDB;
+ MultiXactOffset oldestOffset;
/*
* This is what the previous checkpoint stored as the truncate position.
@@ -949,14 +955,16 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* against catastrophic data loss due to multixact wraparound. The basic
* rules are:
*
- * If we're past multiVacLimit, start trying to force autovacuum cycles.
+ * If we're past multiVacLimit or the safe threshold for member storage space,
+ * start trying to force autovacuum cycles.
* If we're past multiWarnLimit, start issuing warnings.
* If we're past multiStopLimit, refuse to create new MultiXactIds.
*
* Note these are pretty much the same protections in GetNewTransactionId.
*----------
*/
- if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit))
+ if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit) ||
+ (MultiXactState->nextOffset - MultiXactState->oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD))
{
/*
* For safety's sake, we release MultiXactGenLock while sending
@@ -2477,6 +2485,7 @@ static void
DetermineSafeOldestOffset(MultiXactId oldestMXact)
{
MultiXactOffset oldestOffset;
+ MultiXactOffset startOfOldestSegment;
/*
* Can't do this while initdb'ing or in the startup process while
@@ -2495,12 +2504,14 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
*/
oldestOffset = find_multixact_start(oldestMXact);
/* move back to start of the corresponding segment */
- oldestOffset -= oldestOffset / MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT;
+ startOfOldestSegment = oldestOffset -
+ (oldestOffset % (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT));
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
/* always leave one segment before the wraparound point */
- MultiXactState->offsetStopLimit = oldestOffset -
+ MultiXactState->offsetStopLimit = startOfOldestSegment -
(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ MultiXactState->oldestOffset = oldestOffset;
LWLockRelease(MultiXactGenLock);
}
@@ -2578,6 +2589,87 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Determine how many multixacts, and how many multixact members, currently
+ * exist.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ oldestOffset = MultiXactState->oldestOffset;
+ LWLockRelease(MultiXactGenLock);
+
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Multixact members can be removed once the multixacts that refer to them
+ * are older than every datminxmid. autovacuum_multixact_freeze_max_age and
+ * vacuum_multixact_freeze_table_age work together to make sure we never have
+ * too many multixacts; we hope that, at least under normal circumstances,
+ * this will also be sufficient to keep us from using too many offsets.
+ * However, if the average multixact has many members, we might exhaust the
+ * members space while still using few enough members that these limits fail
+ * to trigger full table scans for relminmxid advancement. At that point,
+ * we'd have no choice but to start failing multixact-creating operations
+ * with an error.
+ *
+ * To prevent that, if more than a threshold portion of the members space is
+ * used, we effectively reduce autovacuum_multixact_freeze_max_age and
+ * vacuum_multixact_freeze_table_age to a value just less than the number of
+ * multixacts in use. We hope that this will quickly trigger autovacuuming on
+ * the table or tables with the oldest relminmxid, thus allowing datminmxid
+ * values to advance and removing some members.
+ *
+ * As the fraction of the member space currently in use grows, we become
+ * more aggressive in clamping these values, so that autovacuum will begin
+ * working on more and more tables, and any manual vacuums the user issues
+ * will also become more aggressive. When it gets high enough, we assume
+ * the situation is desperate and treat both values as zero, essentially
+ * freezing every possible multixact.
+ *
+ * It's possible that these thresholds should be user-tunable, but for now
+ * we keep it simple.
+ */
+int
+MultiXactMemberFreezeThreshold(void)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ uint32 victim_multixacts;
+ double fraction;
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ /* If member space utilization is low, no special action is required. */
+ if (members <= MULTIXACT_MEMBER_SAFE_THRESHOLD)
+ return -1;
+
+ /*
+ * Compute a target for relminmxid advancement. The number of multixacts
+ * we try to eliminate from the system is based on how far we are past
+ * MULTIXACT_MEMBER_SAFE_THRESHOLD.
+ */
+ fraction = (double) (members - MULTIXACT_MEMBER_SAFE_THRESHOLD) /
+ (MULTIXACT_MEMBER_DANGER_THRESHOLD - MULTIXACT_MEMBER_SAFE_THRESHOLD);
+ victim_multixacts = multixacts * fraction;
+
+ /* fraction could be > 1.0, but lowest possible freeze age is zero */
+ if (victim_multixacts > multixacts)
+ return 0;
+ return multixacts - victim_multixacts;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..0b5ab40 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -92,10 +92,7 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
Assert((vacstmt->options & VACOPT_ANALYZE) || vacstmt->va_cols == NIL);
Assert(!(vacstmt->options & VACOPT_SKIPTOAST));
- /*
- * All freeze ages are zero if the FREEZE option is given; otherwise pass
- * them as -1 which means to use the default values.
- */
+ /* All freeze ages are zero if the FREEZE option is given. */
if (vacstmt->options & VACOPT_FREEZE)
{
params.freeze_min_age = 0;
@@ -105,10 +102,26 @@ ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
}
else
{
+ int multixact_member_max_age;
+
+ /* Use defaults. */
params.freeze_min_age = -1;
params.freeze_table_age = -1;
params.multixact_freeze_min_age = -1;
params.multixact_freeze_table_age = -1;
+
+ /*
+ * Override the multixact freeze settings if we're using too much
+ * member address space. It's a bit of kludge to do this here,
+ * but if we pushed it down into vacuum(), autovacuum workers would
+ * repeat this calculation for every table.
+ */
+ multixact_member_max_age = MultiXactMemberFreezeThreshold();
+ if (multixact_member_max_age >= 0)
+ {
+ params.multixact_freeze_table_age = multixact_member_max_age;
+ params.multixact_freeze_min_age = multixact_member_max_age / 2;
+ }
}
/* user-invoked vacuum is never "for wraparound" */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..db73886 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int multixact_member_max_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_member_max_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1077,6 +1079,7 @@ do_start_worker(void)
Oid retval = InvalidOid;
MemoryContext tmpcxt,
oldcxt;
+ int multixact_member_max_age;
/* return quickly when there are no free workers */
LWLockAcquire(AutovacuumLock, LW_SHARED);
@@ -1118,7 +1121,12 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multixact_member_max_age = MultiXactMemberFreezeThreshold();
+ if (multixact_member_max_age >= 0)
+ multiForceLimit = recentMulti - Min(autovacuum_freeze_max_age,
+ multixact_member_max_age);
+ else
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1889,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int multixact_member_max_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1959,6 +1968,12 @@ do_autovacuum(void)
HASH_ELEM | HASH_BLOBS);
/*
+ * Determine whether we need to freeze multixacts more aggressively due
+ * to high multixact member utilization.
+ */
+ multixact_member_max_age = MultiXactMemberFreezeThreshold();
+
+ /*
* Scan pg_class to determine which tables to vacuum.
*
* We do this in two passes: on the first one we collect the list of plain
@@ -2001,6 +2016,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ multixact_member_max_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2145,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ multixact_member_max_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2252,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ multixact_member_max_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2460,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int multixact_member_max_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2507,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ multixact_member_max_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2550,6 +2570,18 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ /*
+ * Override the multixact freeze settings if we're using too much
+ * member address space.
+ */
+ if (multixact_member_max_age >= 0)
+ {
+ multixact_freeze_table_age = Min(multixact_member_max_age,
+ multixact_freeze_table_age);
+ multixact_freeze_min_age = Min(multixact_member_max_age / 2,
+ multixact_freeze_min_age);
+ }
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_vacoptions = VACOPT_SKIPTOAST |
@@ -2606,8 +2638,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
* analyze. This is asymmetric to the VACUUM case.
*
* We also force vacuum if the table's relfrozenxid is more than freeze_max_age
- * transactions back, and if its relminmxid is more than
- * multixact_freeze_max_age multixacts back.
+ * transactions back, or if its relminmxid is more than
+ * multixact_freeze_max_age or multixact_member_max_age multixacts back.
*
* A table whose autovacuum_enabled option is false is
* automatically skipped (unless we have to vacuum it due to freeze_max_age).
@@ -2624,6 +2656,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_member_max_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2687,6 +2720,11 @@ relation_needs_vacanalyze(Oid relid,
? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
: autovacuum_multixact_freeze_max_age;
+ /* Special settings if too much multixact member space is in use. */
+ if (multixact_member_max_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age,
+ multixact_member_max_age);
+
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..9353289 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactMemberFreezeThreshold(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-07 14:02 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-07 15:05 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
1 sibling, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-05-07 14:02 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Thomas Munro <thomas.munro@enterprisedb.com> wrote:
> I noticed that oldestOffset's computation to find the start of
> the segment seems wrong in master, I think it should be like
> this, no?
The change you show looks to me like the right way to take
oldestOffset and reduce to the first on a page. Without your
suggested change the calculation lands the value at a location that
has no real meaning.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 14:02 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-05-07 15:05 ` Kevin Grittner <kgrittn@ymail.com>
0 siblings, 0 replies; 113+ messages in thread
From: Kevin Grittner @ 2015-05-07 15:05 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Kevin Grittner <kgrittn@ymail.com> wrote:
> The change you show looks to me like the right way to take
> oldestOffset and reduce to the first on a page.
Of course, I meant the first offset on the first page of a segment.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-07 15:04 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-07 15:04 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 12:23 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> This patch will change it anyway, but I noticed that oldestOffset's
> computation to find the start of the segment seems wrong in master, I
> think it should be like this, no?
>
> @@ -2495,7 +2495,7 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
> */
> oldestOffset = find_multixact_start(oldestMXact);
> /* move back to start of the corresponding segment */
> - oldestOffset -= oldestOffset / MULTIXACT_MEMBERS_PER_PAGE *
> SLRU_PAGES_PER_SEGMENT;
> + oldestOffset -= oldestOffset % (MULTIXACT_MEMBERS_PER_PAGE *
> SLRU_PAGES_PER_SEGMENT);
>
> LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
> /* always leave one segment before the wraparound point */
This should be committed and back-patched separately, I think. I'll
go do that now.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 15:18 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-07 15:18 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas wrote:
> On Thu, May 7, 2015 at 12:23 AM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
> > This patch will change it anyway, but I noticed that oldestOffset's
> > computation to find the start of the segment seems wrong in master, I
> > think it should be like this, no?
> This should be committed and back-patched separately, I think. I'll
> go do that now.
I was going to say the same. Thanks.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-07 15:30 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-07 15:30 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 11:18 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>> On Thu, May 7, 2015 at 12:23 AM, Thomas Munro
>> <thomas.munro@enterprisedb.com> wrote:
>> > This patch will change it anyway, but I noticed that oldestOffset's
>> > computation to find the start of the segment seems wrong in master, I
>> > think it should be like this, no?
>
>> This should be committed and back-patched separately, I think. I'll
>> go do that now.
>
> I was going to say the same. Thanks.
OK, so here is what's in Thomas's latest version that's not already
committed and different from my last version. It should apply on top
of my multixact-av.patch, but I attach it here as a separate extract
for ease of review. I think what we need to determine is whether this
is the right fix for the problem of starting emergency autovacuums for
member space exhaustion even when autovacuum=off.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
tdm-delta.patch (binary/octet-stream, 2.5K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1424cab..ddedade 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -204,6 +204,7 @@ typedef struct MultiXactStateData
*/
MultiXactId oldestMultiXactId;
Oid oldestMultiXactDB;
+ MultiXactOffset oldestOffset;
/*
* This is what the previous checkpoint stored as the truncate position.
@@ -954,14 +955,16 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* against catastrophic data loss due to multixact wraparound. The basic
* rules are:
*
- * If we're past multiVacLimit, start trying to force autovacuum cycles.
+ * If we're past multiVacLimit or the safe threshold for member storage space,
+ * start trying to force autovacuum cycles.
* If we're past multiWarnLimit, start issuing warnings.
* If we're past multiStopLimit, refuse to create new MultiXactIds.
*
* Note these are pretty much the same protections in GetNewTransactionId.
*----------
*/
- if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit))
+ if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit) ||
+ (MultiXactState->nextOffset - MultiXactState->oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD))
{
/*
* For safety's sake, we release MultiXactGenLock while sending
@@ -2482,6 +2485,7 @@ static void
DetermineSafeOldestOffset(MultiXactId oldestMXact)
{
MultiXactOffset oldestOffset;
+ MultiXactOffset startOfOldestSegment;
/*
* Can't do this while initdb'ing or in the startup process while
@@ -2505,8 +2509,9 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
/* always leave one segment before the wraparound point */
- MultiXactState->offsetStopLimit = oldestOffset -
+ MultiXactState->offsetStopLimit = startOfOldestSegment -
(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ MultiXactState->oldestOffset = oldestOffset;
LWLockRelease(MultiXactGenLock);
}
@@ -2599,9 +2604,9 @@ ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
nextOffset = MultiXactState->nextOffset;
oldestMultiXactId = MultiXactState->oldestMultiXactId;
nextMultiXactId = MultiXactState->nextMXact;
+ oldestOffset = MultiXactState->oldestOffset;
LWLockRelease(MultiXactGenLock);
- oldestOffset = find_multixact_start(oldestMultiXactId);
*members = nextOffset - oldestOffset;
*multixacts = nextMultiXactId - oldestMultiXactId;
}
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 16:39 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-07 16:39 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 11:30 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> OK, so here is what's in Thomas's latest version that's not already
> committed and different from my last version. It should apply on top
> of my multixact-av.patch, but I attach it here as a separate extract
> for ease of review. I think what we need to determine is whether this
> is the right fix for the problem of starting emergency autovacuums for
> member space exhaustion even when autovacuum=off.
Nope, I extracted that incorrectly. Second try attached.
I think Thomas's question upthread is a very good one:
> See attached patch, based on your multixact-av.patch. With autovacuum
> set to off, it vacuums as expected. I wonder if
> DetermineSafeOdlestOffset is being called in all the right places to
> guarantee that the state is initialised.
It seems to me that the most obvious places where
DetermineSafeOldestOffset() should be called are (1) at startup or
after recovery, to initialize the value; and (2) each time we truncate
the SLRU, to update the value. Other than that, this doesn't change.
The startup calls are there, in apparently reasonable places, but it's
not obvious to me how this gets called in the TruncateMultiXact path.
Instead it seems to get set via the SetMultiXactIdLimit path. Maybe
that's OK, but it would seem to imply that we're OK with overwriting
old members information if that information was slated for truncation
at the next checkpoint anyway, which seems scary. Wouldn't it be
better to only advance the threshold once the checkpoint completes and
the truncation is done?
Maybe I'm misreading something here.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
tdm-delta-v2.patch (binary/octet-stream, 2.8K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1424cab..7f6536b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -204,6 +204,7 @@ typedef struct MultiXactStateData
*/
MultiXactId oldestMultiXactId;
Oid oldestMultiXactDB;
+ MultiXactOffset oldestOffset;
/*
* This is what the previous checkpoint stored as the truncate position.
@@ -954,14 +955,17 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* against catastrophic data loss due to multixact wraparound. The basic
* rules are:
*
- * If we're past multiVacLimit, start trying to force autovacuum cycles.
+ * If we're past multiVacLimit or the safe threshold for member storage space,
+ * start trying to force autovacuum cycles.
* If we're past multiWarnLimit, start issuing warnings.
* If we're past multiStopLimit, refuse to create new MultiXactIds.
*
* Note these are pretty much the same protections in GetNewTransactionId.
*----------
*/
- if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit))
+ if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit) ||
+ (MultiXactState->nextOffset - MultiXactState->oldestOffset
+ > MULTIXACT_MEMBER_SAFE_THRESHOLD))
{
/*
* For safety's sake, we release MultiXactGenLock while sending
@@ -2482,6 +2486,7 @@ static void
DetermineSafeOldestOffset(MultiXactId oldestMXact)
{
MultiXactOffset oldestOffset;
+ MultiXactOffset startOfOldestSegment;
/*
* Can't do this while initdb'ing or in the startup process while
@@ -2500,13 +2505,14 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
*/
oldestOffset = find_multixact_start(oldestMXact);
/* move back to start of the corresponding segment */
- oldestOffset -= oldestOffset %
- (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ startOfOldestSegment = oldestOffset -
+ (oldestOffset % (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT));
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
/* always leave one segment before the wraparound point */
- MultiXactState->offsetStopLimit = oldestOffset -
+ MultiXactState->offsetStopLimit = startOfOldestSegment -
(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ MultiXactState->oldestOffset = oldestOffset;
LWLockRelease(MultiXactGenLock);
}
@@ -2599,9 +2605,9 @@ ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
nextOffset = MultiXactState->nextOffset;
oldestMultiXactId = MultiXactState->oldestMultiXactId;
nextMultiXactId = MultiXactState->nextMXact;
+ oldestOffset = MultiXactState->oldestOffset;
LWLockRelease(MultiXactGenLock);
- oldestOffset = find_multixact_start(oldestMultiXactId);
*members = nextOffset - oldestOffset;
*multixacts = nextMultiXactId - oldestMultiXactId;
}
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 18:00 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 18:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-08 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 3 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-07 18:00 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas wrote:
> It seems to me that the most obvious places where
> DetermineSafeOldestOffset() should be called are (1) at startup or
> after recovery, to initialize the value; and (2) each time we truncate
> the SLRU, to update the value. Other than that, this doesn't change.
> The startup calls are there, in apparently reasonable places, but it's
> not obvious to me how this gets called in the TruncateMultiXact path.
> Instead it seems to get set via the SetMultiXactIdLimit path. Maybe
> that's OK, but it would seem to imply that we're OK with overwriting
> old members information if that information was slated for truncation
> at the next checkpoint anyway, which seems scary.
I considered this question in the previous commit: is it okay to
overwrite a file that is no longer used (per the limits set by vacuum)
but not yet removed (by checkpoint)? It seems to me that there is no
data-loss issue with doing that -- which is why the advance-oldest code
is called during vacuum and not during checkpoint.
> Wouldn't it be better to only advance the threshold once the
> checkpoint completes and the truncation is done?
*shrug*
There's also a question about this function's "else" branch:
void
MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
else
DetermineSafeOldestOffset(oldestMulti);
}
The reason the "else" is there is that I chickened out about not calling
DetermineSafeOldestOffset() (which SetMultiXactIdLimit calls) when the
oldestMulti does not advance; what if in the previous run we failed to
get to this point for whatever reason? The calls to SetMultiXactIdLimit
are seldom enough that it seemed better to be protected against previous
runs not finishing. Then again, I might be worrying over nothing and
this is just dead code.
Also, if we have extra calls in other places after Thomas' patch,
perhaps this one is not necessary.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-07 18:32 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-07 18:32 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 2:00 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>> It seems to me that the most obvious places where
>> DetermineSafeOldestOffset() should be called are (1) at startup or
>> after recovery, to initialize the value; and (2) each time we truncate
>> the SLRU, to update the value. Other than that, this doesn't change.
>> The startup calls are there, in apparently reasonable places, but it's
>> not obvious to me how this gets called in the TruncateMultiXact path.
>> Instead it seems to get set via the SetMultiXactIdLimit path. Maybe
>> that's OK, but it would seem to imply that we're OK with overwriting
>> old members information if that information was slated for truncation
>> at the next checkpoint anyway, which seems scary.
>
> I considered this question in the previous commit: is it okay to
> overwrite a file that is no longer used (per the limits set by vacuum)
> but not yet removed (by checkpoint)? It seems to me that there is no
> data-loss issue with doing that -- which is why the advance-oldest code
> is called during vacuum and not during checkpoint.
I think the main question is whether truncation will be smart enough
to zap the non-overwritten part of the old stuff but not the part that
did get overwritten.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 18:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 18:39 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-07 18:39 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas wrote:
> On Thu, May 7, 2015 at 2:00 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> > I considered this question in the previous commit: is it okay to
> > overwrite a file that is no longer used (per the limits set by vacuum)
> > but not yet removed (by checkpoint)? It seems to me that there is no
> > data-loss issue with doing that -- which is why the advance-oldest code
> > is called during vacuum and not during checkpoint.
>
> I think the main question is whether truncation will be smart enough
> to zap the non-overwritten part of the old stuff but not the part that
> did get overwritten.
TruncateMultiXact bases its removal of member files on the point set by
checkpoint, MultiXactState->lastCheckpointedOldest. I tested this back
then and there was no issue.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-07 22:21 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-07 22:21 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Fri, May 8, 2015 at 6:00 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>
>> It seems to me that the most obvious places where
>> DetermineSafeOldestOffset() should be called are (1) at startup or
>> after recovery, to initialize the value; and (2) each time we truncate
>> the SLRU, to update the value. Other than that, this doesn't change.
>> The startup calls are there, in apparently reasonable places, but it's
>> not obvious to me how this gets called in the TruncateMultiXact path.
>> Instead it seems to get set via the SetMultiXactIdLimit path. Maybe
>> that's OK, but it would seem to imply that we're OK with overwriting
>> old members information if that information was slated for truncation
>> at the next checkpoint anyway, which seems scary.
>
> I considered this question in the previous commit: is it okay to
> overwrite a file that is no longer used (per the limits set by vacuum)
> but not yet removed (by checkpoint)? It seems to me that there is no
> data-loss issue with doing that -- which is why the advance-oldest code
> is called during vacuum and not during checkpoint.
Given three concurrent backends that are checkpointing, vacuuming and
creating multixacts, isn't there some ordering of events that could
cause SlruScanDirCbRemoveMembers to delete a segment file that it
judges to be the tail segment, but which has become the new head
segment just before the file gets unlinked? The comment in
SlrScanDirCbRemoveMembers says "... and we never increase rangeStart
during any one run", but I think that a concurrent vacuum could
advance the oldest multixact and therefore the oldest offset (which is
what range->rangeStart was derived from), and if you're extra unlucky,
a third backend that is creating multixacts could then advance
nextOffset so that it points to a page *past* range->rangeStart, and
we'd start blowing away the wrong data.
I may have the details wrong there, but in general I can't see how you
can delete just the right segment files while the head and tail
pointers of this circular buffer are both moving, unless you hold the
lock to stop that while you make the decision and unlink the file
(which I assume is out of the question), or say 'well if we keep the
head and tail pointers at least 20 pages apart, that's unlikely to
happen' (which I assume is also out of the question). Now I
understand the suggestion that the checkpoint code could be in charge
of advancing the oldest multixact + offset.
But if we did that, our new autovacuum code would get confused and
keep trying to vacuum stuff that it's already dealt with, until the
next checkpoint... so maybe we'd need to track both (1) the offset of
the oldest multixact: the one that we use to trigger autovacuums, even
though there might be even older segments still on disk, and (2)
offset_of_start_of_oldest_segment_on_disk (suitably compressed): the
one that we use to block wraparound in GetNewMultiXactId, so that we
never write into a file that checkpoint might decide to delete.
> Also, if we have extra calls in other places after Thomas' patch,
> perhaps this one is not necessary.
No extra calls added.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-07 23:58 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-07 23:58 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On May 7, 2015, at 6:21 PM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
> I may have the details wrong there, but in general I can't see how you
> can delete just the right segment files while the head and tail
> pointers of this circular buffer are both moving, unless you hold the
> lock to stop that while you make the decision and unlink the file
> (which I assume is out of the question), or say 'well if we keep the
> head and tail pointers at least 20 pages apart, that's unlikely to
> happen' (which I assume is also out of the question).
That is exactly the sort of thing I was worried about, but I couldn't put my finger on it. I think your analysis is right.
> Now I
> understand the suggestion that the checkpoint code could be in charge
> of advancing the oldest multixact + offset.
Yeah. I think we need to pursue that angle unless somebody has a better idea. It would also address another issue I am concerned about: the current system seems to advance the oldest multixact information in shared memory differently on the primary and the standby. I'm not sure the logic actually works on the standby at all at this point, but even if it does, it seems unlikely be right to rely on redo to do on the standby what is being done by a completely different, not-WAL-logged operation on the master. Making the checkpoint do it in both cases would fix that.
> But if we did that, our new autovacuum code would get confused and
> keep trying to vacuum stuff that it's already dealt with, until the
> next checkpoint... so maybe we'd need to track both (1) the offset of
> the oldest multixact: the one that we use to trigger autovacuums, even
> though there might be even older segments still on disk, and (2)
> offset_of_start_of_oldest_segment_on_disk (suitably compressed): the
> one that we use to block wraparound in GetNewMultiXactId, so that we
> never write into a file that checkpoint might decide to delete.
That sounds plausible.
...Robert
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-08 06:25 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-08 06:25 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 7:58 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> Now I
>> understand the suggestion that the checkpoint code could be in charge
>> of advancing the oldest multixact + offset.
>
> Yeah. I think we need to pursue that angle unless somebody has a better idea.
So here's a patch that does that. It turns out to be pretty simple: I
just moved the DetermineSafeOldestOffset() calls around. As far as I
can see, and that may not be far enough at this hour of the morning,
we just need two: one in StartupMultiXact, so that we initialize the
values correctly after reading the control file; and then another at
the very end of TruncateMultiXact, so we update it after each
checkpoint or restartpoint. This leaves the residual problem that
autovacuum doesn't directly advance the stop point - the following
checkpoint does. We could handle that by requesting a checkpoint if
oldestMultiXactId is ahead of lastCheckpointedOldest by enough that a
checkpoint would free up some space, although one might hope that
people won't be living on the edge to quite that degree.
As things are, I believe this sequence is possible:
1. The members SLRU is full all the way up to offsetStopLimit.
2. A checkpoint occurs, reaching MultiXactSetSafeTruncate(), which
sets lastCheckpointedOldest.
3. Vacuum runs, calling SetMultiXactIdLimit(), calling
DetermineSafeOldestOffset(), advancing
MultiXactState->offsetStopLimit.
4. Since offsetStopLimit > lastCheckpointedOffset, it's now possible
for someone to consume an MXID greater than offsetStopLimit, making
MultiXactState->nextOffset > lastCheckpointedOffset
5. The checkpoint from step 1, continuing on its merry way, now calls
TruncateMultiXact(), which sets rangeEnd > rangeStart and blows away
nearly every file in the SLRU.
I haven't confirmed this yet, so I might still be all wet, especially
since it is late here.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
multixact-truncate-race.patch (binary/octet-stream, 3.1K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index cbb69f5..7ba4e10 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2038,8 +2038,6 @@ TrimMultiXact(void)
}
LWLockRelease(MultiXactMemberControlLock);
-
- DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
/*
@@ -2143,13 +2141,11 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
Assert(MultiXactIdIsValid(oldest_datminmxid));
/*
- * Since multixacts wrap differently from transaction IDs, this logic is
- * not entirely correct: in some scenarios we could go for longer than 2
- * billion multixacts without seeing any data loss, and in some others we
- * could get in trouble before that if the new pg_multixact/members data
- * stomps on the previous cycle's data. For lack of a better mechanism we
- * use the same logic as for transaction IDs, that is, start taking action
- * halfway around the oldest potentially-existing multixact.
+ * We pretend that a wrap will happen halfway through the multixact ID
+ * space, but that's not really true, because multixacts wrap differently
+ * from transaction IDs. Note that, separately from any concern about
+ * multixact IDs wrapping, we must ensure that multixact members do not
+ * wrap. Limits for that are set in DetermineSafeOldestOffset, not here.
*/
multiWrapLimit = oldest_datminmxid + (MaxMultiXactId >> 1);
if (multiWrapLimit < FirstMultiXactId)
@@ -2204,8 +2200,6 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
curMulti = MultiXactState->nextMXact;
LWLockRelease(MultiXactGenLock);
- DetermineSafeOldestOffset(oldest_datminmxid);
-
/* Log the info */
ereport(DEBUG1,
(errmsg("MultiXactId wrap limit is %u, limited by database with OID %u",
@@ -2300,8 +2294,6 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
- else
- DetermineSafeOldestOffset(oldestMulti);
}
/*
@@ -2479,14 +2471,6 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
MultiXactOffset oldestOffset;
/*
- * Can't do this while initdb'ing or in the startup process while
- * replaying WAL: the segment file to read might have not yet been
- * created, or already been removed.
- */
- if (IsBootstrapProcessingMode() || InRecovery)
- return;
-
- /*
* We determine the safe upper bound for offsets of new xacts by reading
* the offset of the oldest multixact, and going back one segment. This
* way, the sequence of multixact member segments will always have a
@@ -2734,6 +2718,13 @@ TruncateMultiXact(void)
SimpleLruTruncate(MultiXactOffsetCtl,
MultiXactIdToOffsetPage(oldestMXact));
+
+ /*
+ * Now, and only now, we can advance the stop point for multixact members.
+ * If we did it any sooner, the segments we deleted above might already
+ * have been overwritten with new members. That would be bad.
+ */
+ DetermineSafeOldestOffset(oldestMXact);
}
/*
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-08 23:41 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-08 23:41 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Fri, May 8, 2015 at 6:25 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> 1. The members SLRU is full all the way up to offsetStopLimit.
> 2. A checkpoint occurs, reaching MultiXactSetSafeTruncate(), which
> sets lastCheckpointedOldest.
> 3. Vacuum runs, calling SetMultiXactIdLimit(), calling
> DetermineSafeOldestOffset(), advancing
> MultiXactState->offsetStopLimit.
> 4. Since offsetStopLimit > lastCheckpointedOffset, it's now possible
> for someone to consume an MXID greater than offsetStopLimit, making
> MultiXactState->nextOffset > lastCheckpointedOffset
> 5. The checkpoint from step 1, continuing on its merry way, now calls
> TruncateMultiXact(), which sets rangeEnd > rangeStart and blows away
> nearly every file in the SLRU.
I am still working on reproducing this race scenario various different
ways including the way you described, but at step 4 I kept getting
stuck, unable to create new multixacts despite having vacuum-frozen
all databases (including template0) and advanced the cluster minimum
mxid.
I think I see why, and I think it's a bug: if you vacuum freeze all
your databases, MultiXactState->oldestMultiXactId finishes up equal to
MultiXactState->nextMXact. But that's not actually a multixact that
exists yet, so when when DetermineSafeOldestOffset calls
find_multixact_start, it reads a garbage offset (all zeros in practice
since pages start out zeroed) and produces a garbage value for
offsetStopLimit which might incorrectly stop you from creating any
more multixacts even though member space is entirely empty (but it
depends on where your nextOffset happens to be at the time). I think
the fix is something like "if nextMXact == oldestMultiXactId, then
there are no active multixacts, so the offsetStopLimit should be set
to nextOffset - (a segment's worth)".
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-09 01:55 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-09 01:55 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
Thomas Munro wrote:
> I think I see why, and I think it's a bug: if you vacuum freeze all
> your databases, MultiXactState->oldestMultiXactId finishes up equal to
> MultiXactState->nextMXact.
Uhm, that's rather silly.
> But that's not actually a multixact that exists yet, so when when
> DetermineSafeOldestOffset calls find_multixact_start, it reads a
> garbage offset (all zeros in practice since pages start out zeroed)
> and produces a garbage value for offsetStopLimit which might
> incorrectly stop you from creating any more multixacts even though
> member space is entirely empty (but it depends on where your
> nextOffset happens to be at the time).
Right.
> I think the fix is something like "if nextMXact == oldestMultiXactId,
> then there are no active multixacts, so the offsetStopLimit should be
> set to nextOffset - (a segment's worth)".
Makes sense.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-09 02:46 ` Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 02:05 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-09 02:46 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Fri, May 8, 2015 at 9:55 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Thomas Munro wrote:
>> I think I see why, and I think it's a bug: if you vacuum freeze all
>> your databases, MultiXactState->oldestMultiXactId finishes up equal to
>> MultiXactState->nextMXact.
>
> Uhm, that's rather silly.
>
>> But that's not actually a multixact that exists yet, so when when
>> DetermineSafeOldestOffset calls find_multixact_start, it reads a
>> garbage offset (all zeros in practice since pages start out zeroed)
>> and produces a garbage value for offsetStopLimit which might
>> incorrectly stop you from creating any more multixacts even though
>> member space is entirely empty (but it depends on where your
>> nextOffset happens to be at the time).
>
> Right.
>
>> I think the fix is something like "if nextMXact == oldestMultiXactId,
>> then there are no active multixacts, so the offsetStopLimit should be
>> set to nextOffset - (a segment's worth)".
>
> Makes sense.
Here's a patch that attempts to implement this.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
no-multixacts-fix.patch (application/x-patch, 1.4K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index fb2edf5..127fe54 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2492,13 +2492,24 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
return;
/*
- * We determine the safe upper bound for offsets of new xacts by reading
- * the offset of the oldest multixact, and going back one segment. This
- * way, the sequence of multixact member segments will always have a
- * one-segment hole at a minimum. We start spewing warnings a few
- * complete segments before that.
+ * Determine the offset of the oldest multixact. Normally, we can read
+ * the offset from the multixact itself, but there's an important special
+ * case: if there are no multixacts in existence at all, oldestMXact
+ * obviously can't point to one. It will instead point to the multixact
+ * ID that will be assigned the next time one is needed.
*/
- oldestOffset = find_multixact_start(oldestMXact);
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ if (MultiXactState->nextMXact == oldestMXact)
+ {
+ oldestOffset = MultiXactState->nextOffset;
+ LWLockRelease(MultiXactGenLock);
+ }
+ else
+ {
+ LWLockRelease(MultiXactGenLock);
+ oldestOffset = find_multixact_start(oldestMXact);
+ }
+
/* move back to start of the corresponding segment */
oldestOffset -= oldestOffset %
(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-09 12:00 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 12:43 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
1 sibling, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-09 12:00 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Sat, May 9, 2015 at 2:46 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Fri, May 8, 2015 at 9:55 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>> Thomas Munro wrote:
>>> I think the fix is something like "if nextMXact == oldestMultiXactId,
>>> then there are no active multixacts, so the offsetStopLimit should be
>>> set to nextOffset - (a segment's worth)".
>>
>> Makes sense.
>
> Here's a patch that attempts to implement this.
Thanks. I think I have managed to reproduce something like the data
loss race that we were speculating about.
0. initdb, autovacuum = off, set up explode_mxact_members.c as
described elsewhere in the thread.
1. Fill up the members SLRU completely (ie reach state where you can
no longer create a new multixact of any size). pg_multixact/members
contains 82040 files and the last one is named 14077.
2. Issue CHECKPOINT, but use a debugger to stop inside
TruncateMultiXact after it has read
MultiXactState->lastCheckpointedOldest and released the lock, but
before it calls SlruScanDirectory to delete files...
3. Run VACUUM FREEZE in all databases (including template0). datminmxid moves.
4. Create lots of new multixacts. pg_multixact/members now contains
82041 files and the last one is named 14078 (ie one extra segment,
with the highest possible segment number, which couldn't be created
before vacuuming because of the one segment gap enforced by
DetermineSafeOldestOffset). Segments 0000-0016 have new modified
times.
5. ... allow the checkpoint started in step 2 to continue. It
deletes segments, keeping only 0000-0016. The segment 14078 which
contained active member data has been incorrectly deleted.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-09 12:43 ` Robert Haas <robertmhaas@gmail.com>
2015-05-09 21:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-05-09 12:43 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On May 9, 2015, at 8:00 AM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>> On Sat, May 9, 2015 at 2:46 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>>> On Fri, May 8, 2015 at 9:55 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>> Thomas Munro wrote:
>>>> I think the fix is something like "if nextMXact == oldestMultiXactId,
>>>> then there are no active multixacts, so the offsetStopLimit should be
>>>> set to nextOffset - (a segment's worth)".
>>>
>>> Makes sense.
>>
>> Here's a patch that attempts to implement this.
>
> Thanks. I think I have managed to reproduce something like the data
> loss race that we were speculating about.
>
> 0. initdb, autovacuum = off, set up explode_mxact_members.c as
> described elsewhere in the thread.
> 1. Fill up the members SLRU completely (ie reach state where you can
> no longer create a new multixact of any size). pg_multixact/members
> contains 82040 files and the last one is named 14077.
> 2. Issue CHECKPOINT, but use a debugger to stop inside
> TruncateMultiXact after it has read
> MultiXactState->lastCheckpointedOldest and released the lock, but
> before it calls SlruScanDirectory to delete files...
> 3. Run VACUUM FREEZE in all databases (including template0). datminmxid moves.
> 4. Create lots of new multixacts. pg_multixact/members now contains
> 82041 files and the last one is named 14078 (ie one extra segment,
> with the highest possible segment number, which couldn't be created
> before vacuuming because of the one segment gap enforced by
> DetermineSafeOldestOffset). Segments 0000-0016 have new modified
> times.
> 5. ... allow the checkpoint started in step 2 to continue. It
> deletes segments, keeping only 0000-0016. The segment 14078 which
> contained active member data has been incorrectly deleted.
OK. So the next question is: if you then apply the other patch, does that prevent step 4 and thereby avoid catastrophe?
...Robert
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 12:43 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-09 21:41 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 02:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-09 21:41 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Sun, May 10, 2015 at 12:43 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On May 9, 2015, at 8:00 AM, Thomas Munro <thomas.munro@enterprisedb.com> wrote:
>>> On Sat, May 9, 2015 at 2:46 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>>>> On Fri, May 8, 2015 at 9:55 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>>> Thomas Munro wrote:
>>>>> I think the fix is something like "if nextMXact == oldestMultiXactId,
>>>>> then there are no active multixacts, so the offsetStopLimit should be
>>>>> set to nextOffset - (a segment's worth)".
>>>>
>>>> Makes sense.
>>>
>>> Here's a patch that attempts to implement this.
>>
>> Thanks. I think I have managed to reproduce something like the data
>> loss race that we were speculating about.
>>
>> 0. initdb, autovacuum = off, set up explode_mxact_members.c as
>> described elsewhere in the thread.
>> 1. Fill up the members SLRU completely (ie reach state where you can
>> no longer create a new multixact of any size). pg_multixact/members
>> contains 82040 files and the last one is named 14077.
>> 2. Issue CHECKPOINT, but use a debugger to stop inside
>> TruncateMultiXact after it has read
>> MultiXactState->lastCheckpointedOldest and released the lock, but
>> before it calls SlruScanDirectory to delete files...
>> 3. Run VACUUM FREEZE in all databases (including template0). datminmxid moves.
>> 4. Create lots of new multixacts. pg_multixact/members now contains
>> 82041 files and the last one is named 14078 (ie one extra segment,
>> with the highest possible segment number, which couldn't be created
>> before vacuuming because of the one segment gap enforced by
>> DetermineSafeOldestOffset). Segments 0000-0016 have new modified
>> times.
>> 5. ... allow the checkpoint started in step 2 to continue. It
>> deletes segments, keeping only 0000-0016. The segment 14078 which
>> contained active member data has been incorrectly deleted.
>
> OK. So the next question is: if you then apply the other patch, does that prevent step 4 and thereby avoid catastrophe?
Yes, in a quick test, at step 4 I couldn't proceed. I need to prod
this some more on Monday, and also see how it interacts with
autovacuum's view of what work needs to be done.
Here is my attempt at a summary. In master, we have 3 arbitrarily
overlapping processes:
1. VACUUM advances oldest multixact and member tail.
2. CHECKPOINT observes member tail and head (separately) and then
deletes storage.
3. Regular transaction obverses tail, checks boundary and advances head.
Information flows from 1 to 2, from 3 to 2, and from 1 to 3. 2
doesn't have a consistent view of head and tail, and doesn't prevent
them moving while deleting storage, so the effect is that we can
delete the wrong range of storage.
With the patch, we have 3 arbitrarily overlapping processes:
1. VACUUM advances oldest multixact.
2. CHECKPOINT observes oldest multixact, deletes storage and then
advances member tail.
3. Regular transaction observes member tail, checks boundary and
advances member head.
Information flows from 1 to 2 and from 2 to 3. Although 2 works with
a snapshot of the oldest multixact which may move before it deletes
storage, 2 knows that the member tail isn't moving (that is its job),
and that 3 can't move the head past the the tail (or rather the stop
limit which is the tail minus a gap), so the effect of using an out of
date oldest multixact is that we err on the side of being too
conservative with our allocation of member space, which is good.
I suppose you could have a workload that eats member space really fast
and checkpoints too infrequently so that you run out of space before a
checkpoint advances the tail. I think that is why you were suggesting
triggering checkpoints automatically in some cases. But I think that
would be a pretty insane workload (I can't convince my computer to
consume 2^32 member elements in under a couple of hours using the
pathological explode_mxact_members.c workload, and you can't set
checkpoint time above 1 hour).
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 12:43 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 21:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-11 02:45 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 11:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-11 02:45 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Sun, May 10, 2015 at 9:41 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Sun, May 10, 2015 at 12:43 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>> OK. So the next question is: if you then apply the other patch, does that prevent step 4 and thereby avoid catastrophe?
>
> Yes, in a quick test, at step 4 I couldn't proceed. I need to prod
> this some more on Monday, and also see how it interacts with
> autovacuum's view of what work needs to be done.
The code in master which handles regular autovacuums seems correct
with this patch, because it measures member space usage by calling
find_multixact_start itself with the oldest multixact ID (it's not
dependent on anything that is updated at checkpoint time).
The code in the patch at
http://www.postgresql.org/message-id/CA+TgmobbaQpE6sNqT30+rz4UMH5aPraq20gko5xd2ZGajz1-Jg@mail.gmail....
would become wrong though, because it would use the (new) variable
MultiXactState->oldestOffset (set at checkpoint) to measure the used
member space. That means it would repeatedly launch autovacuums, even
after clearing away the problem and advancing the oldest multixact ID,
until the next checkpoint updates that value. In other words, it
can't see its own progress immediately (which is the right approach
for blocking new multixact generation, ie defer until
checkpoint/truncation, but the wrong approach for triggering
autovacuums).
I think vacuum (SetMultiXactIdLimit?) needs to update oldestOffset,
not checkpoint (DetermineSafeOldestOffset). (The reason for wanting
this new value in shared memory is because GetNextMultiXactId needs to
be able to check it cheaply for every call, so calling
find_multixact_start every time would presumably not fly).
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 12:43 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 21:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 02:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-11 11:56 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 15:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-11 11:56 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Mon, May 11, 2015 at 2:45 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Sun, May 10, 2015 at 9:41 AM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> On Sun, May 10, 2015 at 12:43 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>>> OK. So the next question is: if you then apply the other patch, does that prevent step 4 and thereby avoid catastrophe?
>>
>> Yes, in a quick test, at step 4 I couldn't proceed. I need to prod
>> this some more on Monday, and also see how it interacts with
>> autovacuum's view of what work needs to be done.
>
> The code in master which handles regular autovacuums seems correct
> with this patch, because it measures member space usage by calling
> find_multixact_start itself with the oldest multixact ID (it's not
> dependent on anything that is updated at checkpoint time).
>
> The code in the patch at
> http://www.postgresql.org/message-id/CA+TgmobbaQpE6sNqT30+rz4UMH5aPraq20gko5xd2ZGajz1-Jg@mail.gmail....
> would become wrong though, because it would use the (new) variable
> MultiXactState->oldestOffset (set at checkpoint) to measure the used
> member space. That means it would repeatedly launch autovacuums, even
> after clearing away the problem and advancing the oldest multixact ID,
> until the next checkpoint updates that value. In other words, it
> can't see its own progress immediately (which is the right approach
> for blocking new multixact generation, ie defer until
> checkpoint/truncation, but the wrong approach for triggering
> autovacuums).
>
> I think vacuum (SetMultiXactIdLimit?) needs to update oldestOffset,
> not checkpoint (DetermineSafeOldestOffset). (The reason for wanting
> this new value in shared memory is because GetNextMultiXactId needs to
> be able to check it cheaply for every call, so calling
> find_multixact_start every time would presumably not fly).
Here's a new version of the patch to do that. As before, it tracks
the oldest offset in shared memory, but now that is updated in
SetMultiXactIdLimit, so it is always updated at the same time as
MultiXactState->oldestMultiXactId (at startup and after full scan
vacuums).
The value is used in the following places:
1. GetNewMultiXactId uses it to see if it needs to send
PMSIGNAL_START_AUTOVAC_LAUNCHER to request autovacuums even if
autovacuum is set to off. That is the main purpose of this patch.
(GetNewMultiXactId *doesn't* use it for member wraparound prevention:
that is based on offsetStopLimit, set by checkpoint code after
truncation of physical storage.)
2. SetMultiXactIdLimit itself also uses it to send a
PMSIGNAL_START_AUTOVAC_LAUNCHER signal to the postmaster (according to
comments this allows immediately doing some more vacuuming upon
completion if necessary).
3. ReadMultiXactCounts, called by regular vacuum and autovacuum,
rather than doing its own call to find_multixact_start, now also reads
it from shared memory. (Incidentally the code this replaces suffers
from the problem fixed elsewhere it can call find_multixact_start for
a multixact that doesn't exist yet).
Vacuum runs as expected with with autovacuum off. Do you think we
should be using MULTIXACT_MEMBER_DANGER_THRESHOLD as the trigger level
for forced vacuums instead of MULTIXACT_MEMBER_SAFE_THRESHOLD, or
something else?
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
force-memberspace-autovacuum.patch (application/octet-stream, 4.3K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index be94a87..dd056cd 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -204,6 +204,7 @@ typedef struct MultiXactStateData
*/
MultiXactId oldestMultiXactId;
Oid oldestMultiXactDB;
+ MultiXactOffset oldestOffset;
/*
* This is what the previous checkpoint stored as the truncate position.
@@ -954,14 +955,17 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* against catastrophic data loss due to multixact wraparound. The basic
* rules are:
*
- * If we're past multiVacLimit, start trying to force autovacuum cycles.
+ * If we're past multiVacLimit or the safe threshold for member storage space,
+ * start trying to force autovacuum cycles.
* If we're past multiWarnLimit, start issuing warnings.
* If we're past multiStopLimit, refuse to create new MultiXactIds.
*
* Note these are pretty much the same protections in GetNewTransactionId.
*----------
*/
- if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit))
+ if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit) ||
+ (MultiXactState->nextOffset - MultiXactState->oldestOffset
+ > MULTIXACT_MEMBER_SAFE_THRESHOLD))
{
/*
* For safety's sake, we release MultiXactGenLock while sending
@@ -2142,6 +2146,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
MultiXactId multiStopLimit;
MultiXactId multiWrapLimit;
MultiXactId curMulti;
+ MultiXactOffset oldestOffset;
+ MultiXactOffset nextOffset;
Assert(MultiXactIdIsValid(oldest_datminmxid));
@@ -2194,6 +2200,30 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
if (multiVacLimit < FirstMultiXactId)
multiVacLimit += FirstMultiXactId;
+ /*
+ * Find the member offset of the oldest multixact, if there is one, which
+ * future vacuums and autovacuums will use to judge the amount of member
+ * space that is used.
+ */
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ curMulti = MultiXactState->nextMXact;
+ if (oldest_datminmxid == curMulti)
+ {
+ /*
+ * There are currently no multixacts, so we use the next offset as the
+ * oldest offset. While oldestOffset remains equal to nextOffset,
+ * GetNewMultiXactId and autovacuum will know that member space is
+ * entirely empty. After we release the lock, if a new multixact is
+ * created, its member offset will be nextOffset and nextOffset will
+ * be advanced, so even then this will be the correct value.
+ */
+ oldestOffset = MultiXactState->nextOffset;
+ }
+ LWLockRelease(MultiXactGenLock);
+
+ if (oldest_datminmxid != curMulti)
+ oldestOffset = find_multixact_start(oldest_datminmxid);
+
/* Grab lock for just long enough to set the new limit values */
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->oldestMultiXactId = oldest_datminmxid;
@@ -2202,7 +2232,9 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
MultiXactState->multiWarnLimit = multiWarnLimit;
MultiXactState->multiStopLimit = multiStopLimit;
MultiXactState->multiWrapLimit = multiWrapLimit;
+ MultiXactState->oldestOffset = oldestOffset;
curMulti = MultiXactState->nextMXact;
+ nextOffset = MultiXactState->nextOffset;
LWLockRelease(MultiXactGenLock);
/* Log the info */
@@ -2217,7 +2249,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
* database, it'll call here, and we'll signal the postmaster to start
* another iteration immediately if there are still any old databases.
*/
- if (MultiXactIdPrecedes(multiVacLimit, curMulti) &&
+ if ((MultiXactIdPrecedes(multiVacLimit, curMulti) ||
+ (nextOffset - oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD)) &&
IsUnderPostmaster && !InRecovery)
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
@@ -2594,9 +2627,9 @@ ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
nextOffset = MultiXactState->nextOffset;
oldestMultiXactId = MultiXactState->oldestMultiXactId;
nextMultiXactId = MultiXactState->nextMXact;
+ oldestOffset = MultiXactState->oldestOffset;
LWLockRelease(MultiXactGenLock);
- oldestOffset = find_multixact_start(oldestMultiXactId);
*members = nextOffset - oldestOffset;
*multixacts = nextMultiXactId - oldestMultiXactId;
}
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 12:43 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-09 21:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 02:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 11:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-11 15:00 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-11 15:00 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Mon, May 11, 2015 at 7:56 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Mon, May 11, 2015 at 2:45 PM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> On Sun, May 10, 2015 at 9:41 AM, Thomas Munro
>> <thomas.munro@enterprisedb.com> wrote:
>>> On Sun, May 10, 2015 at 12:43 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>>>> OK. So the next question is: if you then apply the other patch, does that prevent step 4 and thereby avoid catastrophe?
>>>
>>> Yes, in a quick test, at step 4 I couldn't proceed. I need to prod
>>> this some more on Monday, and also see how it interacts with
>>> autovacuum's view of what work needs to be done.
>>
>> The code in master which handles regular autovacuums seems correct
>> with this patch, because it measures member space usage by calling
>> find_multixact_start itself with the oldest multixact ID (it's not
>> dependent on anything that is updated at checkpoint time).
>>
>> The code in the patch at
>> http://www.postgresql.org/message-id/CA+TgmobbaQpE6sNqT30+rz4UMH5aPraq20gko5xd2ZGajz1-Jg@mail.gmail....
>> would become wrong though, because it would use the (new) variable
>> MultiXactState->oldestOffset (set at checkpoint) to measure the used
>> member space. That means it would repeatedly launch autovacuums, even
>> after clearing away the problem and advancing the oldest multixact ID,
>> until the next checkpoint updates that value. In other words, it
>> can't see its own progress immediately (which is the right approach
>> for blocking new multixact generation, ie defer until
>> checkpoint/truncation, but the wrong approach for triggering
>> autovacuums).
>>
>> I think vacuum (SetMultiXactIdLimit?) needs to update oldestOffset,
>> not checkpoint (DetermineSafeOldestOffset). (The reason for wanting
>> this new value in shared memory is because GetNextMultiXactId needs to
>> be able to check it cheaply for every call, so calling
>> find_multixact_start every time would presumably not fly).
>
> Here's a new version of the patch to do that. As before, it tracks
> the oldest offset in shared memory, but now that is updated in
> SetMultiXactIdLimit, so it is always updated at the same time as
> MultiXactState->oldestMultiXactId (at startup and after full scan
> vacuums).
>
> The value is used in the following places:
>
> 1. GetNewMultiXactId uses it to see if it needs to send
> PMSIGNAL_START_AUTOVAC_LAUNCHER to request autovacuums even if
> autovacuum is set to off. That is the main purpose of this patch.
> (GetNewMultiXactId *doesn't* use it for member wraparound prevention:
> that is based on offsetStopLimit, set by checkpoint code after
> truncation of physical storage.)
>
> 2. SetMultiXactIdLimit itself also uses it to send a
> PMSIGNAL_START_AUTOVAC_LAUNCHER signal to the postmaster (according to
> comments this allows immediately doing some more vacuuming upon
> completion if necessary).
>
> 3. ReadMultiXactCounts, called by regular vacuum and autovacuum,
> rather than doing its own call to find_multixact_start, now also reads
> it from shared memory. (Incidentally the code this replaces suffers
> from the problem fixed elsewhere it can call find_multixact_start for
> a multixact that doesn't exist yet).
>
> Vacuum runs as expected with with autovacuum off.
Great. I've committed this and back-patched it with 9.3, after making
your code look a little more like what I already committed for the
same task, and whacking the comments around.
> Do you think we
> should be using MULTIXACT_MEMBER_DANGER_THRESHOLD as the trigger level
> for forced vacuums instead of MULTIXACT_MEMBER_SAFE_THRESHOLD, or
> something else?
No, I think you have it right.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-11 02:05 ` Robert Haas <robertmhaas@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-11 02:05 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Fri, May 8, 2015 at 10:46 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>>> I think the fix is something like "if nextMXact == oldestMultiXactId,
>>> then there are no active multixacts, so the offsetStopLimit should be
>>> set to nextOffset - (a segment's worth)".
>>
>> Makes sense.
>
> Here's a patch that attempts to implement this.
I've now committed and back-patched this.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 15:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-08 05:17 ` Robert Haas <robertmhaas@gmail.com>
2 siblings, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-08 05:17 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Thu, May 7, 2015 at 2:00 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> There's also a question about this function's "else" branch:
>
> void
> MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
> {
> if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
> SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
> else
> DetermineSafeOldestOffset(oldestMulti);
> }
>
> The reason the "else" is there is that I chickened out about not calling
> DetermineSafeOldestOffset() (which SetMultiXactIdLimit calls) when the
> oldestMulti does not advance; what if in the previous run we failed to
> get to this point for whatever reason? The calls to SetMultiXactIdLimit
> are seldom enough that it seemed better to be protected against previous
> runs not finishing. Then again, I might be worrying over nothing and
> this is just dead code.
It's dead code for more pedestrian reasons: MultiXactAdvanceOldest()
is called only from xlog_redo(), but does nothing if InRecovery.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-07 20:32 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 04:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-08 06:00 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Michael Paquier <michael.paquier@gmail.com>
2 siblings, 2 replies; 113+ messages in thread
From: Robert Haas @ 2015-05-07 20:32 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 9:32 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> So here's a new patch, based on your latest version, which looks
> reasonably committable to me. I made a lot of revisions to the
> comments. I changed some variable and function names, too. I also
> reworked the function that determines the accelerated freeze threshold
> because I was afraid that the integer return value might not be large
> enough to accommodate the uint32 result of the derating calculation,
> which would then turn negative. The new logic is also, I believe,
> less vulnerable to floating-point roundoff dangers. And I tightened
> up the documentation.
Here's a new revision of this patch. When I looked into back-patching
this, it conflicted in ExecVacuum(). And the more I thought about
that, the less I liked it, because I think ExecVacuum() is really
intended to translate from the parse tree representation to whatever
internal representation we're going to pass to vacuum, NOT to make
policy decisions. So in the attached version, what I did instead is
modify vacuum_set_xid_limits() to call
MultiXactMemberFreezeThreshold() itself instead of trying to pass that
value down via the vacuum options. It seems to me that this greatly
reduces the chances of inconsistency between member-wrap vacuums and
offset-wrap vacuums. The code seems more elegant, too:
MultiXactMemberFreezeThreshold() now returns
autovacuum_multixact_freeze_max_age rather than -1 when no special
handling is needed to prevent member wraparound, and all of the
callers now find this convention convenient. As a bonus, it now
back-patches to 9.4 without conflicts. There are some conflicts on
9.3 but they don't look bad.
This will need some testing to make sure it still works; I haven't done that.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
multixact-av-v2.patch (binary/octet-stream, 13.1K) download
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 8764e00..dcd9b78 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -628,6 +628,9 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
Like transaction IDs, multixact IDs are implemented as a
32-bit counter and corresponding storage, all of which requires
careful aging management, storage cleanup, and wraparound handling.
+ There is a separate storage area which holds the list of members in
+ each multixact, which also uses a 32-bit counter and which must also
+ be managed.
</para>
<para>
@@ -655,8 +658,11 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
<para>
As a safety device, a whole-table vacuum scan will occur for any table
whose multixact-age is greater than
- <xref linkend="guc-autovacuum-multixact-freeze-max-age">.
- This will occur even if autovacuum is nominally disabled.
+ <xref linkend="guc-autovacuum-multixact-freeze-max-age">. Whole-table
+ vacuum scans will also occur progressively for all tables, starting with
+ those that have the oldest multixact-age, if the amount of used member
+ storage space exceeds the amount 25% of the addressible storage space.
+ These will occur even if autovacuum is nominally disabled.
</para>
</sect3>
</sect2>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index cbb69f5..fb2edf5 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -168,6 +168,11 @@
(MXOffsetToFlagsOffset(xid) + MULTIXACT_FLAGBYTES_PER_GROUP + \
((xid) % MULTIXACT_MEMBERS_PER_MEMBERGROUP) * sizeof(TransactionId))
+/* Multixact members wraparound thresholds. */
+#define MULTIXACT_MEMBER_SAFE_THRESHOLD (MaxMultiXactOffset / 4)
+#define MULTIXACT_MEMBER_DANGER_THRESHOLD \
+ (MaxMultiXactOffset - MaxMultiXactOffset / 4)
+
/*
* Links to shared-memory data structures for MultiXact control
@@ -2579,6 +2584,89 @@ find_multixact_start(MultiXactId multi)
}
/*
+ * Determine how many multixacts, and how many multixact members, currently
+ * exist.
+ */
+static void
+ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+ MultiXactId nextMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ nextMultiXactId = MultiXactState->nextMXact;
+ LWLockRelease(MultiXactGenLock);
+
+ oldestOffset = find_multixact_start(oldestMultiXactId);
+ *members = nextOffset - oldestOffset;
+ *multixacts = nextMultiXactId - oldestMultiXactId;
+}
+
+/*
+ * Multixact members can be removed once the multixacts that refer to them
+ * are older than every datminxmid. autovacuum_multixact_freeze_max_age and
+ * vacuum_multixact_freeze_table_age work together to make sure we never have
+ * too many multixacts; we hope that, at least under normal circumstances,
+ * this will also be sufficient to keep us from using too many offsets.
+ * However, if the average multixact has many members, we might exhaust the
+ * members space while still using few enough members that these limits fail
+ * to trigger full table scans for relminmxid advancement. At that point,
+ * we'd have no choice but to start failing multixact-creating operations
+ * with an error.
+ *
+ * To prevent that, if more than a threshold portion of the members space is
+ * used, we effectively reduce autovacuum_multixact_freeze_max_age and
+ * to a value just less than the number of multixacts in use. We hope that
+ * this will quickly trigger autovacuuming on the table or tables with the
+ * oldest relminmxid, thus allowing datminmxid values to advance and removing
+ * some members.
+ *
+ * As the fraction of the member space currently in use grows, we become
+ * more aggressive in clamping this value. That not only causes autovacuum
+ * to ramp up, but also makes any manual vacuums the user issues more
+ * aggressive. This happens because vacuum_set_xid_limits() clamps the
+ * freeze table and and the minimum freeze age based on the effective
+ * autovacuum_multixact_freeze_max_age this function returns. In the worst
+ * case, we'll claim the freeze_max_age to zero, and every vacuum of any
+ * table will try to freeze every multixact.
+ *
+ * It's possible that these thresholds should be user-tunable, but for now
+ * we keep it simple.
+ */
+int
+MultiXactMemberFreezeThreshold(void)
+{
+ MultiXactOffset members;
+ uint32 multixacts;
+ uint32 victim_multixacts;
+ double fraction;
+
+ ReadMultiXactCounts(&multixacts, &members);
+
+ /* If member space utilization is low, no special action is required. */
+ if (members <= MULTIXACT_MEMBER_SAFE_THRESHOLD)
+ return autovacuum_multixact_freeze_max_age;
+
+ /*
+ * Compute a target for relminmxid advancement. The number of multixacts
+ * we try to eliminate from the system is based on how far we are past
+ * MULTIXACT_MEMBER_SAFE_THRESHOLD.
+ */
+ fraction = (double) (members - MULTIXACT_MEMBER_SAFE_THRESHOLD) /
+ (MULTIXACT_MEMBER_DANGER_THRESHOLD - MULTIXACT_MEMBER_SAFE_THRESHOLD);
+ victim_multixacts = multixacts * fraction;
+
+ /* fraction could be > 1.0, but lowest possible freeze age is zero */
+ if (victim_multixacts > multixacts)
+ return 0;
+ return multixacts - victim_multixacts;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..34ca325 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -471,6 +471,7 @@ vacuum_set_xid_limits(Relation rel,
{
int freezemin;
int mxid_freezemin;
+ int effective_multixact_freeze_max_age;
TransactionId limit;
TransactionId safeLimit;
MultiXactId mxactLimit;
@@ -528,16 +529,23 @@ vacuum_set_xid_limits(Relation rel,
*freezeLimit = limit;
/*
+ * Compute the multixact age for which freezing is urgent. This is
+ * normally autovacuum_multixact_freeze_max_age, but may be less if we
+ * are short of multixact member space.
+ */
+ effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
+
+ /*
* Determine the minimum multixact freeze age to use: as specified by
* caller, or vacuum_multixact_freeze_min_age, but in any case not more
- * than half autovacuum_multixact_freeze_max_age, so that autovacuums to
+ * than half effective_multixact_freeze_max_age, so that autovacuums to
* prevent MultiXact wraparound won't occur too frequently.
*/
mxid_freezemin = multixact_freeze_min_age;
if (mxid_freezemin < 0)
mxid_freezemin = vacuum_multixact_freeze_min_age;
mxid_freezemin = Min(mxid_freezemin,
- autovacuum_multixact_freeze_max_age / 2);
+ effective_multixact_freeze_max_age / 2);
Assert(mxid_freezemin >= 0);
/* compute the cutoff multi, being careful to generate a valid value */
@@ -546,7 +554,7 @@ vacuum_set_xid_limits(Relation rel,
mxactLimit = FirstMultiXactId;
safeMxactLimit =
- ReadNextMultiXactId() - autovacuum_multixact_freeze_max_age;
+ ReadNextMultiXactId() - effective_multixact_freeze_max_age;
if (safeMxactLimit < FirstMultiXactId)
safeMxactLimit = FirstMultiXactId;
@@ -601,7 +609,7 @@ vacuum_set_xid_limits(Relation rel,
if (freezetable < 0)
freezetable = vacuum_multixact_freeze_table_age;
freezetable = Min(freezetable,
- autovacuum_multixact_freeze_max_age * 0.95);
+ effective_multixact_freeze_max_age * 0.95);
Assert(freezetable >= 0);
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..41bddd6 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -297,10 +297,12 @@ static void do_autovacuum(void);
static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc);
+ TupleDesc pg_class_desc,
+ int effective_multixact_freeze_max_age);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int multixact_member_max_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1118,7 +1120,7 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multiForceLimit = recentMulti - MultiXactMemberFreezeThreshold();
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1881,6 +1883,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
+ int effective_multixact_freeze_max_age;
/*
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -1911,6 +1914,13 @@ do_autovacuum(void)
pgstat_vacuum_stat();
/*
+ * Compute the multixact age for which freezing is urgent. This is
+ * normally autovacuum_multixact_freeze_max_age, but may be less if we
+ * are short of multixact member space.
+ */
+ effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
+
+ /*
* Find the pg_database entry and select the default freeze ages. We use
* zero in template and nonconnectable databases, else the system-wide
* default.
@@ -2001,6 +2011,7 @@ do_autovacuum(void)
/* Check if it needs vacuum or analyze */
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ effective_multixact_freeze_max_age,
&dovacuum, &doanalyze, &wraparound);
/*
@@ -2129,6 +2140,7 @@ do_autovacuum(void)
shared, dbentry);
relation_needs_vacanalyze(relid, relopts, classForm, tabentry,
+ effective_multixact_freeze_max_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore analyze for toast tables */
@@ -2235,7 +2247,8 @@ do_autovacuum(void)
* the race condition is not closed but it is very small.
*/
MemoryContextSwitchTo(AutovacMemCxt);
- tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc);
+ tab = table_recheck_autovac(relid, table_toast_map, pg_class_desc,
+ effective_multixact_freeze_max_age);
if (tab == NULL)
{
/* someone else vacuumed the table, or it went away */
@@ -2442,7 +2455,8 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
*/
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
- TupleDesc pg_class_desc)
+ TupleDesc pg_class_desc,
+ int effective_multixact_freeze_max_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2488,6 +2502,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
shared, dbentry);
relation_needs_vacanalyze(relid, avopts, classForm, tabentry,
+ effective_multixact_freeze_max_age,
&dovacuum, &doanalyze, &wraparound);
/* ignore ANALYZE for toast tables */
@@ -2606,8 +2621,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
* analyze. This is asymmetric to the VACUUM case.
*
* We also force vacuum if the table's relfrozenxid is more than freeze_max_age
- * transactions back, and if its relminmxid is more than
- * multixact_freeze_max_age multixacts back.
+ * transactions back, or if its relminmxid is more than
+ * multixact_freeze_max_age or multixact_member_max_age multixacts back.
*
* A table whose autovacuum_enabled option is false is
* automatically skipped (unless we have to vacuum it due to freeze_max_age).
@@ -2624,6 +2639,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
+ int effective_multixact_freeze_max_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2684,8 +2700,8 @@ relation_needs_vacanalyze(Oid relid,
: autovacuum_freeze_max_age;
multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age >= 0)
- ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
- : autovacuum_multixact_freeze_max_age;
+ ? Min(relopts->multixact_freeze_max_age, effective_multixact_freeze_max_age)
+ : effective_multixact_freeze_max_age;
av_enabled = (relopts ? relopts->enabled : true);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..9353289 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern int MultiXactMemberFreezeThreshold(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 20:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-08 04:26 ` Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 0 replies; 113+ messages in thread
From: Thomas Munro @ 2015-05-08 04:26 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Fri, May 8, 2015 at 8:32 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> Here's a new revision of this patch. When I looked into back-patching
> this, it conflicted in ExecVacuum(). And the more I thought about
> that, the less I liked it, because I think ExecVacuum() is really
> intended to translate from the parse tree representation to whatever
> internal representation we're going to pass to vacuum, NOT to make
> policy decisions. So in the attached version, what I did instead is
> modify vacuum_set_xid_limits() to call
> MultiXactMemberFreezeThreshold() itself instead of trying to pass that
> value down via the vacuum options. It seems to me that this greatly
> reduces the chances of inconsistency between member-wrap vacuums and
> offset-wrap vacuums. The code seems more elegant, too:
> MultiXactMemberFreezeThreshold() now returns
> autovacuum_multixact_freeze_max_age rather than -1 when no special
> handling is needed to prevent member wraparound, and all of the
> callers now find this convention convenient. As a bonus, it now
> back-patches to 9.4 without conflicts. There are some conflicts on
> 9.3 but they don't look bad.
This is definitely tidier.
> This will need some testing to make sure it still works; I haven't done that.
I tested it with autovacuum on, and it automatically vacuumed after
25% of member space was used.
I tested it with autovacuum off, and I ran a VACUUM manually every few
minutes and checked that it didn't advance my database's datminmxid,
until after 25% of member space was used, after which a full scan was
triggered and datminmxid moved. As expected, that didn't advance the
cluster-wide oldest multixact, because for that you'd need to vacuum
ALL databases including non-connectable ones. (This patch doesn't
update the forced-autovacuum-even-if-autovacuum-is-off feature to
handle member space wraparound in GetNextMultiXactId, which is coming
in a separate patch[1].)
So it works as expected.
[1] http://www.postgresql.org/message-id/CA+TgmobbaQpE6sNqT30+rz4UMH5aPraq20gko5xd2ZGajz1-Jg@mail.gmail....
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-07 20:32 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-05-08 06:00 ` Michael Paquier <michael.paquier@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Michael Paquier @ 2015-05-08 06:00 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; Amit Kapila <amit.kapila16@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Fri, May 8, 2015 at 5:32 AM, Robert Haas wrote:
> because I think ExecVacuum() is really
> intended to translate from the parse tree representation to whatever
> internal representation we're going to pass to vacuum, NOT to make
> policy decisions.
Yep. That's more or less the idea behind it.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-02 11:22 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 02:29 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-06 13:18 ` Amit Kapila <amit.kapila16@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Amit Kapila @ 2015-05-06 13:18 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Kevin Grittner <kgrittn@ymail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs
On Wed, May 6, 2015 at 3:56 PM, Thomas Munro <thomas.munro@enterprisedb.com>
wrote:
>
> On Wed, May 6, 2015 at 2:29 PM, Robert Haas <robertmhaas@gmail.com> wrote:
Few comments:
1.
+ /*
+ * Override the multixact freeze settings if we are running out of
+ * member address space.
+ */
+ if (safe_multixact_age >= 0)
+ {
+ multixact_freeze_table_age = Min(safe_multixact_age,
+ multixact_freeze_table_age);
+ /* Special settings if we are running out of member address space. */
+ if (safe_multixact_age >= 0)
+ multixact_freeze_max_age = Min(multixact_freeze_max_age,
safe_multixact_age);
+
Some places use safe_multixact_age as first parameter and some
places use it at second place. I think it is better to use in same
order for the sake of consistency.
2.
in the hope
+ * that different tables will be vacuumed at different times due to their
+ * varying relminmxid values.
Does above line in comment on top of MultiXactCheckMemberUsage()
makes much sense?
3.
+ * we know the age of the oldest multixact in the system, so that's the
+ * value we want to when members is near safe_member_count. It should
typo.
so that's the value we want to *use* when ..
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-04 20:36 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 22:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2 siblings, 1 reply; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-04 20:36 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Thomas Munro wrote:
> FWIW, in some future release, I think we should consider getting a
> bigger multixact member address space that wraps around at 2^48 or
> 2^64 instead of 2^32, so that we can sidestep the whole business and
> go back to having just xid and mxid wraparounds to worry about.
> pg_multixact/offsets would be 50% or 100% bigger (an extra byte or two
> per multixact), but it's not very big. pg_multiact/members would be
> no bigger for any workload that currently works without hitting the
> wraparound error, but could grow bigger if needed.
Not sure that enlarging the addressable area to 48/64 bits is feasible,
TBH. We already have many complaints that multixacts take too much disk
space; we don't want to make that 2^32 times worse, not even 2^16 times
worse. I don't understand why you say it'd become 1 byte bigger per
multixact; it would have to be 4 more bytes (2^64) or 2 more bytes
(2^48), no? If you have 150 million multixacts (the default freeze
table age) that would mean about 300 or 600 MB of additional disk space,
which is not insignificant: with the current system, in an database with
normal multixact usage of 4 members per multixact, members/ would use
about 2.8 GB, so 600 additional MB in offsets/ is large enough growth to
raise some more complaints.
(The 2^48 suggestion might be a tad more difficult to implement, note,
becase a lot of stuff relies on unsigned integer wraparound addition,
and I'm not sure we can have that with a 2^48 counter. Maybe we could
figure how to make it work, but is it worth the bother?)
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 20:36 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-05-04 22:51 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 01:03 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-05-04 22:51 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, May 5, 2015 at 8:36 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Thomas Munro wrote:
>
>> FWIW, in some future release, I think we should consider getting a
>> bigger multixact member address space that wraps around at 2^48 or
>> 2^64 instead of 2^32, so that we can sidestep the whole business and
>> go back to having just xid and mxid wraparounds to worry about.
>> pg_multixact/offsets would be 50% or 100% bigger (an extra byte or two
>> per multixact), but it's not very big. pg_multiact/members would be
>> no bigger for any workload that currently works without hitting the
>> wraparound error, but could grow bigger if needed.
>
> Not sure that enlarging the addressable area to 48/64 bits is feasible,
> TBH. We already have many complaints that multixacts take too much disk
> space; we don't want to make that 2^32 times worse, not even 2^16 times
> worse. I don't understand why you say it'd become 1 byte bigger per
> multixact; it would have to be 4 more bytes (2^64) or 2 more bytes
> (2^48), no? If you have 150 million multixacts (the default freeze
> table age) that would mean about 300 or 600 MB of additional disk space,
> which is not insignificant: with the current system, in an database with
> normal multixact usage of 4 members per multixact, members/ would use
> about 2.8 GB, so 600 additional MB in offsets/ is large enough growth to
> raise some more complaints.
Right, sorry, I must have been thinking of 40 bit or 48 bit indexes
when I said 1 or 2 bytes.
I can't help thinking there must be a different way to do this that
takes advantage of the fact that multixacts are often created by
copying all the members of an existing multixact and adding one new
one, so that there is a lot of duplication and churn (at least when
you have a workload that generates bigger multixacts, due to the
O(n^2) process of building them up xid by xid).
Maybe there is a way to store a pointer to some other multixact + a
new xid in a chain structure, but I don't see how to do the cleanup
when you have active multixacts with backwards references to older
multixacts.
Maybe you could find some way to leave gaps in member space (perhaps
by making member index point to member groups with space for 4 or 8
member xids), and MultiXactIdExpand could create new multixacts that
point to the same member offset but a different size so they see extra
members, but that would also waste disk space, be hard to synchronize
and you'd need to fall back to copying the members into new member
space when the spare space is filled anyway.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 00:14 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 20:36 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 22:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-05-05 01:03 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-05-05 01:03 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Thomas Munro wrote:
> I can't help thinking there must be a different way to do this that
> takes advantage of the fact that multixacts are often created by
> copying all the members of an existing multixact and adding one new
> one, so that there is a lot of duplication and churn (at least when
> you have a workload that generates bigger multixacts, due to the
> O(n^2) process of building them up xid by xid).
Yeah, Simon expressed the same thought to me some months ago, and I gave
it some think-time (but not at lot of it TBH). I didn't see any way to
make it workable.
Normally, lockers go away reasonably quickly, so some of the original
members of the multixact are disappearing all the time. Maybe one way
would be to re-use a multixact you have in your local cache, as long as
the only difference with the multixact you want is some locker
transaction(s) that have already ended. Not sure how you would manage
the cache, though.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-28 14:33 ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:34 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 2 replies; 113+ messages in thread
From: Robert Haas @ 2015-04-28 14:33 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 2:23 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Ah, yeah, we do want the full range; that's already built in the code
> elsewhere.
>
> In this version, I used your WouldWrap function, but there was a bug in
> your formulation of the call site: after the WARNING has been issued
> once, it is never issued again for that wraparound cycle, because the
> second time around the nextOffset has already crossed the boundary and
> your routine returns false. IMO this is wrong and the warning should be
> issued every time. To fix that problem I removed the offsetWarnLimit
> altogether, and instead do WouldWrap() of the value against
> offsetStopLimit minus the 20 segments. That way, the warning is issued
> continuously until the offsetStopLimit is reached (once there,
> obviously, only the error is thrown, not the warning, which is correct.)
>
> I also added a call to DetermineSafeOldestOffset() in TrimMultiXact:
> as far as I can tell, this is necessary for the time when a standby
> exits recovery, because when InRecovery we return early from
> DetermineSafeOldestOffset() so the safe point would never get set.
Putting the period inside the parentheses here looks weird?
+ "This command would create a
multixact with %u members, which exceeds remaining space (%u
members.)",
Maybe rephrase as: "This command would create a multixact with %u
members, but the remaining space is only enough for %u members."
I don't think this should have a comma:
+ errhint("Execute a database-wide VACUUM in that
database, with reduced vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.")));
This looks like excess brace-ifiaction:
+ if (start < boundary)
+ {
+ return finish >= boundary || finish < start;
+ }
+ else
+ {
+ return finish >= boundary && finish < start;
+ }
I think this is confusing:
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-28 14:34 ` Robert Haas <robertmhaas@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-04-28 14:34 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 10:33 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> I think this is confusing:
Oops, hit send too soon.
+/*
+ * Read the offset of the first member of the given multixact.
+ */
This is confusing to me because the two subdirectories of pg_multixact
are called "members" and "offsets". Here you are talking about the
offset of the first member. Maybe I'm just slow, but that seems like
conflating terminology. You end up with a function called
read_offset_for_multi() that is actually looking up information about
members. Ick.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-28 14:56 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 16:04 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-28 14:56 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
I sure wish this had arrived two minutes earlier ...
Robert Haas wrote:
> Putting the period inside the parentheses here looks weird?
>
> + "This command would create a
> multixact with %u members, which exceeds remaining space (%u
> members.)",
>
> Maybe rephrase as: "This command would create a multixact with %u
> members, but the remaining space is only enough for %u members."
WFM, will change.
> I don't think this should have a comma:
>
> + errhint("Execute a database-wide VACUUM in that
> database, with reduced vacuum_multixact_freeze_min_age and
> vacuum_multixact_freeze_table_age settings.")));
Ditto.
> This looks like excess brace-ifiaction:
>
> + if (start < boundary)
> + {
> + return finish >= boundary || finish < start;
> + }
> + else
> + {
> + return finish >= boundary && finish < start;
> + }
Yeah, agreed. Will undo that change. (I disliked the comment above the
indented single-statement, so added braces, but then moved the comment.
I should have removed the braces at that point.)
> I think this is confusing:
>
> +/*
> + * Read the offset of the first member of the given multixact.
> + */
>
> This is confusing to me because the two subdirectories of pg_multixact
> are called "members" and "offsets". Here you are talking about the
> offset of the first member. Maybe I'm just slow, but that seems like
> conflating terminology. You end up with a function called
> read_offset_for_multi() that is actually looking up information about
> members. Ick.
Yeah, I introduced the confusing terminology while inventing multixacts
initially and have regretted it many times. I will think about a better
name for this. (Meanwhile, on IM Robert suggested
find_start_of_first_multi_member)
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-28 16:04 ` Robert Haas <robertmhaas@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Robert Haas @ 2015-04-28 16:04 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 10:56 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> I sure wish this had arrived two minutes earlier ...
Sorry about that. :-)
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-28 17:54 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
2015-04-30 03:52 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
1 sibling, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-28 17:54 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Alvaro Herrera wrote:
> > I think this is confusing:
> >
> > +/*
> > + * Read the offset of the first member of the given multixact.
> > + */
> >
> > This is confusing to me because the two subdirectories of pg_multixact
> > are called "members" and "offsets". Here you are talking about the
> > offset of the first member. Maybe I'm just slow, but that seems like
> > conflating terminology. You end up with a function called
> > read_offset_for_multi() that is actually looking up information about
> > members. Ick.
>
> Yeah, I introduced the confusing terminology while inventing multixacts
> initially and have regretted it many times. I will think about a better
> name for this. (Meanwhile, on IM Robert suggested
> find_start_of_first_multi_member)
Pushed. I chose find_multixact_start() as a name for this function.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-28 18:13 ` Jeff Janes <jeff.janes@gmail.com>
2015-04-28 18:52 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 23:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 2 replies; 113+ messages in thread
From: Jeff Janes @ 2015-04-28 18:13 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 10:54 AM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> Alvaro Herrera wrote:
>
> > > I think this is confusing:
> > >
> > > +/*
> > > + * Read the offset of the first member of the given multixact.
> > > + */
> > >
> > > This is confusing to me because the two subdirectories of pg_multixact
> > > are called "members" and "offsets". Here you are talking about the
> > > offset of the first member. Maybe I'm just slow, but that seems like
> > > conflating terminology. You end up with a function called
> > > read_offset_for_multi() that is actually looking up information about
> > > members. Ick.
> >
> > Yeah, I introduced the confusing terminology while inventing multixacts
> > initially and have regretted it many times. I will think about a better
> > name for this. (Meanwhile, on IM Robert suggested
> > find_start_of_first_multi_member)
>
> Pushed. I chose find_multixact_start() as a name for this function.
>
Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this
just-described commit, I can no longer upgrade from a 9.2.10 database using
pg_upgrade.
I can reproduce it from a clean 9.2 install which has never even been
started up.
Deleting files from new pg_multixact/offsets ok
Setting oldest multixact ID on new cluster ok
Resetting WAL archives ok
*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.
The last few lines are:
command: "../bisect/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D
"../data2/" -o "-p 50432 -b -c synchronous_commit=off -c fsync=off -c
full_page_writes=off -c listen_addresses='' -c
unix_socket_permissions=0700 -c
unix_socket_directories='/home/jjanes/pgsql/git'" start >>
"pg_upgrade_server.log" 2>&1
waiting for server to start....LOG: database system was shut down at
2015-04-28 11:08:18 PDT
FATAL: could not access status of transaction 1
DETAIL: Could not open file "pg_multixact/offsets/0000": No such file or
directory.
LOG: startup process (PID 3977) exited with exit code 1
LOG: aborting startup due to startup process failure
Cheers,
Jeff
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
@ 2015-04-28 18:52 ` Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-28 18:52 UTC (permalink / raw)
To: Jeff Janes <jeff.janes@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Jeff Janes wrote:
> Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this
> just-described commit, I can no longer upgrade from a 9.2.10 database using
> pg_upgrade.
How annoying, thanks for the report. I reproduced it here. The problem
is that the upgrade process removes the files from pg_multixact/offsets,
which is what we now want to read on startup. Not yet sure how to fix
it.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
@ 2015-04-28 23:13 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-29 17:07 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
2015-04-30 13:02 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
1 sibling, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-28 23:13 UTC (permalink / raw)
To: Jeff Janes <jeff.janes@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Jeff Janes wrote:
> Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this
> just-described commit, I can no longer upgrade from a 9.2.10 database using
> pg_upgrade.
Here's a patch, but I don't like it too much. Will think more about it,
probably going to push something tomorrow.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
memberswrap-3.patch (text/x-diff, 5.7K) download
commit b7538e5da55eb8e69021ccb2c7bca0d0019be6c3
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Tue Apr 28 19:15:02 2015 -0300
fix boot after pg_upgrade
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 06bcd52..6e0e870 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1042,9 +1042,9 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
ExtendMultiXactOffset(result);
/*
- * Reserve the members space, similarly to above. Also, be careful not to
- * return zero as the starting offset for any multixact. See
- * GetMultiXactIdMembers() for motivation.
+ * Compute the members space we need. Be careful not to return zero as the
+ * starting offset for any multixact. See GetMultiXactIdMembers() for
+ * motivation.
*/
nextOffset = MultiXactState->nextOffset;
if (nextOffset == 0)
@@ -1096,6 +1096,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
MultiXactState->offsetStopLimit - nextOffset + nmembers),
errhint("Execute a database-wide VACUUM in that database with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
+ /* And make sure there is room in the members files */
ExtendMultiXactMember(nextOffset, nmembers);
/*
@@ -1938,6 +1939,17 @@ MaybeExtendOffsetSlru(void)
}
LWLockRelease(MultiXactOffsetControlLock);
+
+ /* also create member page 0, also removed by pg_upgrade */
+ LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
+ if (!SimpleLruDoesPhysicalPageExist(MultiXactMemberCtl, 0))
+ {
+ int slotno;
+
+ slotno = ZeroMultiXactMemberPage(0, false);
+ SimpleLruWritePage(MultiXactMemberCtl, slotno);
+ }
+ LWLockRelease(MultiXactMemberControlLock);
}
/*
@@ -1966,12 +1978,6 @@ StartupMultiXact(void)
*/
pageno = MXOffsetToMemberPage(offset);
MultiXactMemberCtl->shared->latest_page_number = pageno;
-
- /*
- * compute the oldest member we need to keep around to avoid old member
- * data overrun.
- */
- DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
/*
@@ -2145,7 +2151,8 @@ MultiXactSetNextMXact(MultiXactId nextMulti,
* of our cluster), and the OID of the (or a) database with that value.
*/
void
-SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
+SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
+ bool compute_offset_limit)
{
MultiXactId multiVacLimit;
MultiXactId multiWarnLimit;
@@ -2217,7 +2224,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
curMulti = MultiXactState->nextMXact;
LWLockRelease(MultiXactGenLock);
- DetermineSafeOldestOffset(oldest_datminmxid);
+ if (compute_offset_limit)
+ DetermineSafeOldestOffset(oldest_datminmxid);
/* Log the info */
ereport(DEBUG1,
@@ -2312,7 +2320,7 @@ void
MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
- SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
+ SetMultiXactIdLimit(oldestMulti, oldestMultiDB, true);
else
DetermineSafeOldestOffset(oldestMulti);
}
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c52f94c..ba2f236 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4061,7 +4061,7 @@ BootStrapXLOG(void)
ShmemVariableCache->oidCount = 0;
MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);
SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);
- SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB);
+ SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB, false);
/* Set up the XLOG page header */
page->xlp_magic = XLOG_PAGE_MAGIC;
@@ -5290,7 +5290,7 @@ StartupXLOG(void)
ShmemVariableCache->oidCount = 0;
MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);
SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);
- SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB);
+ SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB, false);
MultiXactSetSafeTruncate(checkPoint.oldestMulti);
XLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch;
XLogCtl->ckptXid = checkPoint.nextXid;
@@ -8133,7 +8133,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
MultiXactSetNextMXact(checkPoint.nextMulti,
checkPoint.nextMultiOffset);
SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);
- SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB);
+ SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB, true);
MultiXactSetSafeTruncate(checkPoint.oldestMulti);
/*
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index ba3fbbd..746a093 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -1093,7 +1093,7 @@ vac_truncate_clog(TransactionId frozenXID,
* signalling twice?
*/
SetTransactionIdLimit(frozenXID, oldestxid_datoid);
- SetMultiXactIdLimit(minMulti, minmulti_datoid);
+ SetMultiXactIdLimit(minMulti, minmulti_datoid, true);
}
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index e69a3d2..3ad8d16 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -111,7 +111,7 @@ extern void StartupMultiXact(void);
extern void TrimMultiXact(void);
extern void ShutdownMultiXact(void);
extern void SetMultiXactIdLimit(MultiXactId oldest_datminmxid,
- Oid oldest_datoid);
+ Oid oldest_datoid, bool compute_offset_limit);
extern void MultiXactGetCheckptMulti(bool is_shutdown,
MultiXactId *nextMulti,
MultiXactOffset *nextMultiOffset,
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
2015-04-28 23:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-29 17:07 ` Jeff Janes <jeff.janes@gmail.com>
2015-04-30 17:03 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 113+ messages in thread
From: Jeff Janes @ 2015-04-29 17:07 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 4:13 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> Jeff Janes wrote:
> > Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this
> > just-described commit, I can no longer upgrade from a 9.2.10 database
> using
> > pg_upgrade.
>
> Here's a patch, but I don't like it too much. Will think more about it,
> probably going to push something tomorrow.
>
It looks like that patch is targeted to 9.4 branch. I couldn't readily get
it to apply on HEAD. I tested it on 9.4, and it solved the problem there.
Thanks,
Jeff
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
2015-04-28 23:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-29 17:07 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
@ 2015-04-30 17:03 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-30 17:03 UTC (permalink / raw)
To: Jeff Janes <jeff.janes@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Jeff Janes wrote:
> On Tue, Apr 28, 2015 at 4:13 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
> wrote:
>
> > Jeff Janes wrote:
> > > Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to
> > > this just-described commit, I can no longer upgrade from a 9.2.10
> > > database using pg_upgrade.
> >
> > Here's a patch, but I don't like it too much. Will think more about it,
> > probably going to push something tomorrow.
>
> It looks like that patch is targeted to 9.4 branch. I couldn't readily get
> it to apply on HEAD. I tested it on 9.4, and it solved the problem there.
Yeah, I wrote it in 9.3. However, it was wrong; or at least there's a
better way to formulate it, and the new formulation applies without
conflict from 9.3 to master. So I pushed that instead.
Thanks!
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
2015-04-28 23:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-30 13:02 ` Robert Haas <robertmhaas@gmail.com>
2015-04-30 16:51 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-04-30 13:02 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Jeff Janes <jeff.janes@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 7:13 PM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Jeff Janes wrote:
>> Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this
>> just-described commit, I can no longer upgrade from a 9.2.10 database using
>> pg_upgrade.
>
> Here's a patch, but I don't like it too much. Will think more about it,
> probably going to push something tomorrow.
What don't you like about it? We should get something committed here;
it's not good for the back-branches to be in a state where pg_upgrade
will break.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Jeff Janes <jeff.janes@gmail.com>
2015-04-28 23:13 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-30 13:02 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-30 16:51 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-30 16:51 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Jeff Janes <jeff.janes@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
Robert Haas wrote:
> On Tue, Apr 28, 2015 at 7:13 PM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:
> > Jeff Janes wrote:
> >> Starting with commit b69bf30b9bfacafc733a9ba7 and continuing to this
> >> just-described commit, I can no longer upgrade from a 9.2.10 database using
> >> pg_upgrade.
> >
> > Here's a patch, but I don't like it too much. Will think more about it,
> > probably going to push something tomorrow.
>
> What don't you like about it? We should get something committed here;
> it's not good for the back-branches to be in a state where pg_upgrade
> will break.
Yeah, I managed to find a real fix which I will push shortly.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 17:54 ` Re: Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-30 03:52 ` Amit Kapila <amit.kapila16@gmail.com>
1 sibling, 0 replies; 113+ messages in thread
From: Amit Kapila @ 2015-04-30 03:52 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 28, 2015 at 11:24 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
>
> Alvaro Herrera wrote:
>
>
> Pushed. I chose find_multixact_start() as a name for this function.
>
I have done test to ensure that the latest change has fixed the
reported problem and below are the results, to me it looks the
reported problem is fixed.
I have used test (explode_mxact_members) developed by Thomas
to reproduce the problem. Start one transaction in a session.
After running the test for 3~4 hours with parameters as
explode_mxact_members 500 35000, I could see the warning messages
like below (before the fix there were no such messages and test is
completed but it has corrupted the database):
WARNING: database with OID 1 must be vacuumed before 358 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
WARNING: database with OID 1 must be vacuumed before 310 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
WARNING: database with OID 1 must be vacuumed before 261 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
WARNING: database with OID 1 must be vacuumed before 211 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
WARNING: database with OID 1 must be vacuumed before 160 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
explode_mxact_members: explode_mxact_members.c:38: main: Assertion
`PQresultStatus(res) == PGRES_TUPLES_OK'
failed.
After this I set the vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age as zero and then performed
Vacuum freeze for template1 and postgres followed by
manual CHECKPOINT. I could see below values in pg_database.
postgres=# select oid,datname,datminmxid from pg_database;
oid | datname | datminmxid
-------+-----------+------------
1 | template1 | 17111262
13369 | template0 | 17111262
13374 | postgres | 17111262
(3 rows)
Again I start the test as ./explode_mxact_members 500 35000, but it
immediately failed as
500 sessions connected...
Loop 0...
WARNING: database with OID 13369 must be vacuumed before 12 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
WARNING: database with OID 13369 must be vacuumed before 11 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
WARNING: database with OID 13369 must be vacuumed before 9 more multixact
members are used
HINT: Execute a database-wide VACUUM in that database, with reduced
vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age settings.
explode_mxact_members: explode_mxact_members.c:38: main: Assertion
`PQresultStatus(res) == PGRES_TUPLES_OK'
failed.
Now it was confusing for me why it has failed for next time even
though I had Vacuum Freeze and CHECKPOINT, but then I waited
for a minute or two and ran Vacuum Freeze by below command:
./vacuumdb -a -F
vacuumdb: vacuuming database "postgres"
vacuumdb: vacuuming database "template1"
Here I have verified that all files except one were deleted.
After that when I restarted the test, it went perfectly fine and it never
lead to any warning messages, probable because the values for
vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age
were zero.
I am still not sure why it took some time to clean the members directory
and resume the test after running Vacuum Freeze and Checkpoint.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-21 05:12 ` Amit Kapila <amit.kapila16@gmail.com>
2015-04-29 06:10 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2 siblings, 1 reply; 113+ messages in thread
From: Amit Kapila @ 2015-04-21 05:12 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: tgarnett@panjiva.com; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 21, 2015 at 12:34 AM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
>
> Alvaro Herrera wrote:
>
> > The fix is to raise an ERROR when generating a new multixact, if we
> > detect that doing so would get close to the oldest multixact that the
> > system knows about. If that happens, the solution is to vacuum so that
> > the "oldest" point is advanced a bit more and you have room to generate
> > more multixacts. In production, you would typically adjust the
> > multixact freeze parameters so that "oldest multixact" is advanced more
> > aggressively and you don't hit the ERROR.
>
> Here's a patch. I have tested locally and it closes the issue for me.
> If those affected can confirm that it stops the file removal from
> happening, I'd appreciate it.
>
1. Do you think it makes sense to give warning in SetMultiXactIdLimit()
if we have already reached offsetWarnLimit as we give for multiWarnLimit?
2.
void
MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
+ else
+ DetermineSafeOldestOffset(oldestMulti);
}
Why we need to update offset stop/warn limits for the above case?
Won't it make the warning/error (pertaining to wrap around data loss)
to appear before it is required.
3.
@@ -1921,6 +1957,12 @@ StartupMultiXact(void)
*/
pageno = MXOffsetToMemberPage(offset);
MultiXactMemberCtl->shared->latest_page_number = pageno;
+
+ /*
+ * compute the oldest member we need to keep around to avoid old member
+ * data overrun.
+ */
+ DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
Do we need to try determining safeoldestoffset during startup considering
that we don't allow it in recovery (StartupMultiXact() seems to be called
only during recovery)
4.
AuxiliaryProcessMain()
{
..
/*
* XLOG operations
*/
SetProcessingMode(NormalProcessing);
switch (MyAuxProcType)
{
case CheckerProcess:
/* don't set signals, they're useless here */
CheckerModeMain();
proc_exit(1); /* should never return */
case BootstrapProcess:
SetProcessingMode(BootstrapProcessing);
bootstrap_signals();
BootStrapXLOG();
BootstrapModeMain();
proc_exit(1); /* should never return */
..
}
Looking at above code, the new setting of processing mode for
BootstrapProcessing looks slightly unlear, basically first we set
processing mode as Normal and then set it to BootstrapProcessing,
may be we can add a comment there.
This solution seems like a good workaround for the problem reported,
however ideally there should be some way (via Vacuum/
Checkpoint) with which this increase of files can be prevented. I think
after your patch gets committed, we can try to devise a better design
to overcome this problem.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 05:12 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Amit Kapila <amit.kapila16@gmail.com>
@ 2015-04-29 06:10 ` Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 0 replies; 113+ messages in thread
From: Thomas Munro @ 2015-04-29 06:10 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Timothy Garnett <tgarnett@panjiva.com>; pgsql-bugs; Kevin Grittner <kgrittn@ymail.com>
On Tue, Apr 21, 2015 at 5:12 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> On Tue, Apr 21, 2015 at 12:34 AM, Alvaro Herrera <alvherre@2ndquadrant.com>
> wrote:
>>
>> Alvaro Herrera wrote:
>>
>> > The fix is to raise an ERROR when generating a new multixact, if we
>> > detect that doing so would get close to the oldest multixact that the
>> > system knows about. If that happens, the solution is to vacuum so that
>> > the "oldest" point is advanced a bit more and you have room to generate
>> > more multixacts. In production, you would typically adjust the
>> > multixact freeze parameters so that "oldest multixact" is advanced more
>> > aggressively and you don't hit the ERROR.
>>
>> Here's a patch. I have tested locally and it closes the issue for me.
>> If those affected can confirm that it stops the file removal from
>> happening, I'd appreciate it.
>>
>
> 1. Do you think it makes sense to give warning in SetMultiXactIdLimit()
> if we have already reached offsetWarnLimit as we give for multiWarnLimit?
Amit and I discussed this offline. Yes, we could include a warning
message here, for consistency with the warnings you get about xid
wraparound. Concretely I think it means that you would also get
warnings about being being near the member space limit from vacuums,
rather than just from attempts to allocate new multixact IDs. The
test to detect an impending members-would-wrap ERROR would be similar
to what we do in GetNewMultiXactId, so something like:
MultiXactOffsetWouldWrap(offsetStopLimit,
nextOffset,
MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT *
OFFSET_WARN_SEGMENTS)
I'm not sure whether it's worth writing an extra patch for this
though, because if you're in this situation, your logs are already
overflowing with warnings from the regular backends that are
generating multixacts. Thoughts anyone?
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-21 21:16 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2 siblings, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-04-21 21:16 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; +Cc: pgsql-bugs
Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Here's a patch. I have tested locally and it closes the issue
> for me. If those affected can confirm that it stops the file
> removal from happening, I'd appreciate it.
Based on initial testing, it seems to stop file removal from
happening rather too well. Before applying the patch I ran a test
test that generated files 0000 to 1185D in the members directory.
Even setting vacuum_multixact_freeze_min_age and
vacuum_multixact_freeze_table_age very low, none of the members
files would go away with VACUUM (with and without FREEZE) followed
by CHECKPOINT. After applying the patch and starting with a fresh
initdb, with very low settings of the vacuum_multixact_* GUCs I get
the new error almost immediately, while the only file in the
members subdirectory is 0000 and it is 8kB in size.
I think the calculations might be wrong, but I'm not sure what does
make sense.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-04-23 17:18 ` Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 21:34 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
0 siblings, 2 replies; 113+ messages in thread
From: Robert Haas @ 2015-04-23 17:18 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; thomas.munro@enterprisedb.com; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Tue, Apr 21, 2015 at 5:16 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>> Here's a patch. I have tested locally and it closes the issue
>> for me. If those affected can confirm that it stops the file
>> removal from happening, I'd appreciate it.
>
> Based on initial testing, it seems to stop file removal from
> happening rather too well. Before applying the patch I ran a test
> test that generated files 0000 to 1185D in the members directory.
> Even setting vacuum_multixact_freeze_min_age and
> vacuum_multixact_freeze_table_age very low, none of the members
> files would go away with VACUUM (with and without FREEZE) followed
> by CHECKPOINT. After applying the patch and starting with a fresh
> initdb, with very low settings of the vacuum_multixact_* GUCs I get
> the new error almost immediately, while the only file in the
> members subdirectory is 0000 and it is 8kB in size.
>
> I think the calculations might be wrong, but I'm not sure what does
> make sense.
Can anyone else reproduce this?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-24 00:14 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 113+ messages in thread
From: Thomas Munro @ 2015-04-24 00:14 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Fri, Apr 24, 2015 at 5:18 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Tue, Apr 21, 2015 at 5:16 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
>> Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>> Here's a patch. I have tested locally and it closes the issue
>>> for me. If those affected can confirm that it stops the file
>>> removal from happening, I'd appreciate it.
>>
>> Based on initial testing, it seems to stop file removal from
>> happening rather too well. Before applying the patch I ran a test
>> test that generated files 0000 to 1185D in the members directory.
>> Even setting vacuum_multixact_freeze_min_age and
>> vacuum_multixact_freeze_table_age very low, none of the members
>> files would go away with VACUUM (with and without FREEZE) followed
>> by CHECKPOINT. After applying the patch and starting with a fresh
>> initdb, with very low settings of the vacuum_multixact_* GUCs I get
>> the new error almost immediately, while the only file in the
>> members subdirectory is 0000 and it is 8kB in size.
>>
>> I think the calculations might be wrong, but I'm not sure what does
>> make sense.
>
> Can anyone else reproduce this?
Yes. This happens in a fresh initdb-ed database. We start out with
oldestOffset = 0, oldestOffsetStopLimit = 4294914944 (that's 0 -
safety margin), nextOffset = 0. Then the first attempt to generate a
new multixact ID fails, because
MultiXactOffsetPrecedes(oldestOffsetStopLimit, nextOffset + nmembers)
is true. I guess the patch works correctly when you start out with an
unpatched database server and generate more than 2.whatever billion
members, and then you restart with the patch, and then start adding
more members until MultiXactOffsetPrecedes(...) returns true and you
get the error.
That's why I proposed not using xid-like logic, and instead using a
type of three-way comparison that allows you to see when nextOffset
would 'cross' oldestOffsetStopLimit, instead of the two-way comparison
that considers half the number-space to be in the past and half in the
future, in my earlier message.
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
@ 2015-04-24 01:59 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-24 13:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-24 01:59 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Kevin Grittner <kgrittn@ymail.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
Thomas Munro wrote:
> That's why I proposed not using xid-like logic, and instead using a
> type of three-way comparison that allows you to see when nextOffset
> would 'cross' oldestOffsetStopLimit, instead of the two-way comparison
> that considers half the number-space to be in the past and half in the
> future, in my earlier message.
Yeah, that bit made sense to me.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-24 13:18 ` Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-04-24 13:18 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Thu, Apr 23, 2015 at 9:59 PM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Thomas Munro wrote:
>> That's why I proposed not using xid-like logic, and instead using a
>> type of three-way comparison that allows you to see when nextOffset
>> would 'cross' oldestOffsetStopLimit, instead of the two-way comparison
>> that considers half the number-space to be in the past and half in the
>> future, in my earlier message.
>
> Yeah, that bit made sense to me.
In addition to preventing the corruption, I think we also need a
back-patchable fix for AV to try to keep this situation from happening
in the first place. We do not want the system to get stuck in a
situation where member usage is low, so autovacuum does nothing, but
offset usage is high, so the user just keeps getting an error whenever
they do anything that could cause a new MXID to be created. Perhaps
if we'd thought of it we would have added yet another column to
pg_class to track the oldest offset referenced by any MXID in a
particular relation, but that sounds kind of icky on general principle
and certainly wouldn't be back-patchable.
What I think we should do is notice when members utilization exceeds
offset utilization and progressively ramp back the effective value of
autovacuum_multixact_freeze_max_age (and maybe also
vacuum_multixact_freeze_table_age and vacuum_multixact_freeze_min_age)
so that autovacuum (and maybe also manual vacuums) get progressively
more aggressive about trying to advance relminmxid. Suppose we decide
that when the "members" space is 75% used, we've got a big problem and
want to treat autovacuum_multixact_freeze_max_age to effectively be
zero. Conversely, suppose that when the members space is at a lower
usage percentage than the offsets space, or when it's anyway less than
autovacuum_multixact_freeze_max_age, we define that as completely
acceptable. If we're somewhere above the "no problem" threshold but
below the "big problem" threshold, then we calculate what percentage
of the way we are from the "no problem" threshold to the "big problem"
threshold and reduce autovacuum_multixact_freeze_max_age by that
percentage.
Example: autovacuum_multixact_freeze_max_age is 25% of 2^32 and we're
using 20% of the offsets space but 40% of the members space. We're
(40 - 20) / (75 - 20) = 36% of the way to the 75% threshold we never
want to exceed, so we reduce the effective value of
autovacuum_multixact_freeze_max_age by 36%. In this case, that means
treating the configured value of 1073741824 as if it were 1073741824 *
(35/55) = 683290251. Hopefully that's enough to trigger enough
vacuuming to cause some relminmxid advancement, but if not, and the
situation continues to worsen, we'll get more and more aggressive.
This may not be the right proposal in detail, but I think we should do
something. I don't like the idea telling users that they can no
longer count on autovacuum to prevent wraparound, and that if they
don't manually tune their vacuum settings correctly, their system may
just stop working at some point.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-24 13:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-27 14:59 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-27 16:40 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-27 20:11 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) David Gould <daveg@sonic.net>
0 siblings, 2 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-27 14:59 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas wrote:
> On Thu, Apr 23, 2015 at 9:59 PM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:
> > Thomas Munro wrote:
> >> That's why I proposed not using xid-like logic, and instead using a
> >> type of three-way comparison that allows you to see when nextOffset
> >> would 'cross' oldestOffsetStopLimit, instead of the two-way comparison
> >> that considers half the number-space to be in the past and half in the
> >> future, in my earlier message.
> >
> > Yeah, that bit made sense to me.
>
> In addition to preventing the corruption, I think we also need a
> back-patchable fix for AV to try to keep this situation from happening
> in the first place.
Let me push a patch to fix the corruption, and then we can think of ways
to teach autovacuum about the problem. I'm not optimistic about that,
honestly: as all GUC settings, these are individual for each process,
and there's no way for one process to affect the values that are seen by
other processes (autovac workers). The only idea that comes to mind is
to publish values in shared memory, and autovac workers would read them
from there instead of using normal GUC values.
> What I think we should do is notice when members utilization exceeds
> offset utilization and progressively ramp back the effective value of
> autovacuum_multixact_freeze_max_age (and maybe also
> vacuum_multixact_freeze_table_age and vacuum_multixact_freeze_min_age)
> so that autovacuum (and maybe also manual vacuums) get progressively
> more aggressive about trying to advance relminmxid. Suppose we decide
> that when the "members" space is 75% used, we've got a big problem and
> want to treat autovacuum_multixact_freeze_max_age to effectively be
> zero.
I think we can easily determine the rate of multixact member space
consumption and compare to the rate of multixact ID consumption;
considering the historical multixact size (number of members per
multixact) it would be possible to change the freeze ages by the same
fraction, so that autovac effectively behaves as if the members
consumption rate is what is driving the freezing instead of ID
consumption rate. That way, we don't have to jump suddenly from
"normal" to "emergency" behavior as some fixed threshold.
> This may not be the right proposal in detail, but I think we should do
> something.
No disagreement on that.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-24 13:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-27 16:40 ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 00:19 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
1 sibling, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-04-27 16:40 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Mon, Apr 27, 2015 at 10:59 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Let me push a patch to fix the corruption, and then we can think of ways
> to teach autovacuum about the problem.
Sounds good to me. Are you going to do that today?
> I'm not optimistic about that,
> honestly: as all GUC settings, these are individual for each process,
> and there's no way for one process to affect the values that are seen by
> other processes (autovac workers). The only idea that comes to mind is
> to publish values in shared memory, and autovac workers would read them
> from there instead of using normal GUC values.
I don't think we could store values for the parameters directly in
shared memory, because I think that at least some of those GUCs are
per-session changeable. But we might be able to store weighting
factors in shared memory that get applied to whatever the values in
the current session are. Or else maybe each backend can just
recompute the information for itself when it needs it.
>> What I think we should do is notice when members utilization exceeds
>> offset utilization and progressively ramp back the effective value of
>> autovacuum_multixact_freeze_max_age (and maybe also
>> vacuum_multixact_freeze_table_age and vacuum_multixact_freeze_min_age)
>> so that autovacuum (and maybe also manual vacuums) get progressively
>> more aggressive about trying to advance relminmxid. Suppose we decide
>> that when the "members" space is 75% used, we've got a big problem and
>> want to treat autovacuum_multixact_freeze_max_age to effectively be
>> zero.
>
> I think we can easily determine the rate of multixact member space
> consumption and compare to the rate of multixact ID consumption;
> considering the historical multixact size (number of members per
> multixact) it would be possible to change the freeze ages by the same
> fraction, so that autovac effectively behaves as if the members
> consumption rate is what is driving the freezing instead of ID
> consumption rate. That way, we don't have to jump suddenly from
> "normal" to "emergency" behavior as some fixed threshold.
Right. I think that not jumping from normal mode to emergency mode is
quite important, and was trying to describe a system that would
gradually ramp up the pressure rather than a system that would do
nothing for a while and then suddenly go ballistic.
With regard to what you've outlined here, we need to make sure that if
the multixact rate varies widely, we still clean up before we hit
autovac wraparond. That's why I think it should be driven off of the
fraction of the available address space which is currently consumed,
not some kind of short term measure of mxact size or generation rate.
I'm not sure exactly what you have in mind here.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-24 13:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-27 16:40 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-28 00:19 ` Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 0 replies; 113+ messages in thread
From: Thomas Munro @ 2015-04-28 00:19 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Kevin Grittner <kgrittn@ymail.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Tue, Apr 28, 2015 at 4:40 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Mon, Apr 27, 2015 at 10:59 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>> I think we can easily determine the rate of multixact member space
>> consumption and compare to the rate of multixact ID consumption;
>> considering the historical multixact size (number of members per
>> multixact) it would be possible to change the freeze ages by the same
>> fraction, so that autovac effectively behaves as if the members
>> consumption rate is what is driving the freezing instead of ID
>> consumption rate. That way, we don't have to jump suddenly from
>> "normal" to "emergency" behavior as some fixed threshold.
>
> Right. I think that not jumping from normal mode to emergency mode is
> quite important, and was trying to describe a system that would
> gradually ramp up the pressure rather than a system that would do
> nothing for a while and then suddenly go ballistic.
>
> With regard to what you've outlined here, we need to make sure that if
> the multixact rate varies widely, we still clean up before we hit
> autovac wraparond. That's why I think it should be driven off of the
> fraction of the available address space which is currently consumed,
> not some kind of short term measure of mxact size or generation rate.
> I'm not sure exactly what you have in mind here.
Here is a work-in-progress-patch that:
(1) Fixes the boundary bug already discussed (as before, except that I
fixed up the comments in MultiXactOffsetWouldWrap() to survive
pgindent based on feedback from Kevin).
(2) Makes autovacuum adjust the effective value of
autovacuum_multixact_freeze_max_age down to zero as the fraction of
used addressable member offset range approaches 75%, and also makes
vacuum_multixact_freeze_min_age use the same value if it is lower than
the configured min age.
When I run this with my explode_mxact_members.c program, autovacuum
moves datminmxid forwards, avoiding the error. The algorithm in
autovacuum_multixact_freeze_max_age_adjusted is possibly too simple,
but it should at least spread out wraparound autovacuums rather than
suddenly going ballistic.
Do you think it's OK that MultiXactAdvanceNextMXact still uses
MultiXactOffsetPrecedes to compare two member offsets? Can the value
from an XLog record being replayed be more than 2.2 billion away from
MultiXactState->nextOffset?
(The attachment memberswrap-2.patch is a diff against master, and
memberswrap-2-incremental.patch is a diff against master with Alvaro's
patch applied).
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments: download all (2 files, .tar.gz)
memberswrap-2.patch (application/octet-stream, 15.1K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 3dbf6b9..4ac3d69 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -213,6 +213,10 @@ typedef struct MultiXactStateData
MultiXactId multiStopLimit;
MultiXactId multiWrapLimit;
+ /* support for members anti-wraparound measures */
+ MultiXactOffset offsetWarnLimit;
+ MultiXactOffset offsetStopLimit;
+
/*
* Per-backend data starts here. We have two arrays stored in the area
* immediately following the MultiXactStateData struct. Each is indexed by
@@ -341,6 +345,8 @@ static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers);
+static MultiXactOffset read_offset_for_multi(MultiXactId multi);
+static void DetermineSafeOldestOffset(MultiXactId oldestMXact);
static void WriteMZeroPageXlogRec(int pageno, uint8 info);
@@ -902,6 +908,41 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
}
/*
+ * Check if we could add "distance" to "start", without moving past
+ * "boundary", using modulo arithmetic.
+ */
+static bool
+MultiXactOffsetWouldWrap(MultiXactOffset boundary,
+ MultiXactOffset start,
+ int distance)
+{
+ MultiXactOffset finish = start + distance;
+ Assert(distance >= 0);
+ if (start < boundary)
+ /*------------------------------------------------------------
+ *
+ * <----S----B---->
+ *
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [---) = F OK
+ * [----] = F wrapped past B
+ *------------------------------------------------------------
+ */
+ return finish >= boundary || finish < start;
+ else
+ /*------------------------------------------------------------
+ *
+ * <----B----S---->
+ *
+ * [---) = F OK
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [----] = F OK
+ *------------------------------------------------------------
+ */
+ return finish >= boundary && finish < start;
+}
+
+/*
* GetNewMultiXactId
* Get the next MultiXactId.
*
@@ -967,7 +1008,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
/*
* To avoid swamping the postmaster with signals, we issue the autovac
- * request only once per 64K transaction starts. This still gives
+ * request only once per 64K multis generated. This still gives
* plenty of chances before we get into real trouble.
*/
if (IsUnderPostmaster && (result % 65536) == 0)
@@ -1043,6 +1084,36 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
else
*offset = nextOffset;
+ /*
+ * Protect against overrun of the members space as well, with the following
+ * rules:
+ *
+ * - if we're past offsetWarnLimit, emit a warning.
+ * - if we're past offsetStopLimit, refuse to generate more multis.
+ *
+ * Note we haven't updated the shared state yet, so if we fail at this
+ * point, the multixact ID we grabbed can still be used by the next guy.
+ *
+ * Note that thre is no point in forcing autovacuum runs here; the
+ * multixact freeze settings would have to be reduced for that to have any
+ * effect, and we can't do that from here.
+ */
+ if (MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit, nextOffset, nmembers))
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("database is not accepting commands that generate new MultiXactIds to avoid \"members\" wraparound data loss in database with OID %u",
+ MultiXactState->oldestMultiXactDB),
+ errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
+ else if (MultiXactOffsetWouldWrap(MultiXactState->offsetWarnLimit, nextOffset, nmembers))
+ ereport(WARNING,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg_plural("database with OID %u must be vacuumed before %d more multixact member is used",
+ "database with OID %u must be vacuumed before %d more multixact members are used",
+ MultiXactState->offsetStopLimit - nextOffset + nmembers,
+ MultiXactState->oldestMultiXactDB,
+ MultiXactState->offsetStopLimit - nextOffset + nmembers),
+ errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
+
ExtendMultiXactMember(nextOffset, nmembers);
/*
@@ -1899,6 +1970,12 @@ StartupMultiXact(void)
*/
pageno = MXOffsetToMemberPage(offset);
MultiXactMemberCtl->shared->latest_page_number = pageno;
+
+ /*
+ * compute the oldest member we need to keep around to avoid old member
+ * data overrun.
+ */
+ DetermineSafeOldestOffset(MultiXactState->oldestMultiXactId);
}
/*
@@ -2099,7 +2176,7 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
*
* Note: This differs from the magic number used in
* SetTransactionIdLimit() since vacuum itself will never generate new
- * multis.
+ * multis. XXX actually it does, if it needs to freeze old multis.
*/
multiStopLimit = multiWrapLimit - 100;
if (multiStopLimit < FirstMultiXactId)
@@ -2142,6 +2219,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
curMulti = MultiXactState->nextMXact;
LWLockRelease(MultiXactGenLock);
+ DetermineSafeOldestOffset(oldest_datminmxid);
+
/* Log the info */
ereport(DEBUG1,
(errmsg("MultiXactId wrap limit is %u, limited by database with OID %u",
@@ -2228,13 +2307,16 @@ MultiXactAdvanceNextMXact(MultiXactId minMulti,
/*
* Update our oldestMultiXactId value, but only if it's more recent than
- * what we had.
+ * what we had. However, even if not, always update the oldest multixact
+ * offset limit.
*/
void
MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
{
if (MultiXactIdPrecedes(MultiXactState->oldestMultiXactId, oldestMulti))
SetMultiXactIdLimit(oldestMulti, oldestMultiDB);
+ else
+ DetermineSafeOldestOffset(oldestMulti);
}
/*
@@ -2402,6 +2484,93 @@ GetOldestMultiXactId(void)
}
/*
+ * Read the offset of the first member of the given multixact.
+ */
+static MultiXactOffset
+read_offset_for_multi(MultiXactId multi)
+{
+ MultiXactOffset offset;
+ int pageno;
+ int entryno;
+ int slotno;
+ MultiXactOffset *offptr;
+
+ pageno = MultiXactIdToOffsetPage(multi);
+ entryno = MultiXactIdToOffsetEntry(multi);
+
+ /* lock is acquired by SimpleLruReadPage_ReadOnly */
+ slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+ offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
+ offptr += entryno;
+ offset = *offptr;
+ LWLockRelease(MultiXactOffsetControlLock);
+
+ return offset;
+}
+
+/*
+ * Based on the given oldest MultiXactId, determine what's the oldest member
+ * offset and install the limit info in MultiXactState, where it can be used to
+ * prevent overrun of old data in the members SLRU area.
+ */
+static void
+DetermineSafeOldestOffset(MultiXactId oldestMXact)
+{
+ MultiXactOffset oldestOffset;
+
+ /*
+ * Can't do this while initdb'ing or in the startup process while replaying
+ * WAL: the segment file to read might have not yet been created, or
+ * already been removed.
+ */
+ if (IsBootstrapProcessingMode() || InRecovery)
+ return;
+
+ /*
+ * We determine the safe upper bound for offsets of new xacts by reading
+ * the offset of the oldest multixact, and going back one segment. This
+ * way, the sequence of multixact member segments will always have a
+ * one-segment hole at a minimum. We start spewing warnings 19 segments
+ * before that.
+ */
+ oldestOffset = read_offset_for_multi(oldestMXact);
+ /* move back to start of this segment */
+ oldestOffset -= oldestOffset / MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT;
+
+ LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
+ /* always leave one segment before the wraparound point */
+ MultiXactState->offsetStopLimit = oldestOffset -
+ (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
+ /* start complaining 20 segments before the wraparound point */
+ MultiXactState->offsetWarnLimit = oldestOffset -
+ (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT * 20);
+ LWLockRelease(MultiXactGenLock);
+}
+
+/*
+ * Returns an instantaneous snapshot of the current number of members in the
+ * members SLRU area.
+ */
+MultiXactOffset
+ReadMultiXactMemberCount(void)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * TODO: In future, could oldestMultiXactMemberOffset be stored in shmem,
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = read_offset_for_multi(oldestMultiXactId);
+ return nextOffset - oldestOffset;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
@@ -2533,26 +2702,7 @@ TruncateMultiXact(void)
* First, compute the safe truncation point for MultiXactMember. This is
* the starting offset of the oldest multixact.
*/
- {
- int pageno;
- int slotno;
- int entryno;
- MultiXactOffset *offptr;
-
- /* lock is acquired by SimpleLruReadPage_ReadOnly */
-
- pageno = MultiXactIdToOffsetPage(oldestMXact);
- entryno = MultiXactIdToOffsetEntry(oldestMXact);
-
- slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
- oldestMXact);
- offptr = (MultiXactOffset *)
- MultiXactOffsetCtl->shared->page_buffer[slotno];
- offptr += entryno;
- oldestOffset = *offptr;
-
- LWLockRelease(MultiXactOffsetControlLock);
- }
+ oldestOffset = read_offset_for_multi(oldestMXact);
/*
* To truncate MultiXactMembers, we need to figure out the active page
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index ad49964..8e18f85 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -397,6 +397,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
proc_exit(1); /* should never return */
case BootstrapProcess:
+ SetProcessingMode(BootstrapProcessing);
bootstrap_signals();
BootStrapXLOG();
BootstrapModeMain();
@@ -459,8 +460,7 @@ BootstrapModeMain(void)
int i;
Assert(!IsUnderPostmaster);
-
- SetProcessingMode(BootstrapProcessing);
+ Assert(IsBootstrapProcessingMode());
/*
* Do backend-like initialization for bootstrap mode
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..3502a7f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -601,7 +601,7 @@ vacuum_set_xid_limits(Relation rel,
if (freezetable < 0)
freezetable = vacuum_multixact_freeze_table_age;
freezetable = Min(freezetable,
- autovacuum_multixact_freeze_max_age * 0.95);
+ autovacuum_multixact_freeze_max_age_adjusted() * 0.95);
Assert(freezetable >= 0);
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..071d492 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1052,6 +1052,34 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Returns vacuum_multixact_freeze_max_age, adjusted down to prevent excessive use
+ * of addressable multixact member space if required.
+ *
+ * The goal is to avoid the situation where new multixacts can't be created
+ * because the offsets used to address pg_multixact/members would wrap around.
+ *
+ * If less than "safe fraction" of the total available member space is used,
+ * then we make no adjustment. If more than the "excessive fraction" of the
+ * total available member space is used, then we use a freeze max age of zero
+ * to trigger aggressive vacuuming. In between, we scale the given freeze max
+ * age down linearly, so that vacuuming becomes more aggressive as the member
+ * SLRU grows.
+ */
+int
+autovacuum_multixact_freeze_max_age_adjusted()
+{
+ // TODO: where to get these constants?
+ const double safe_fraction = 0.25;
+ const double excessive_fraction = 0.75;
+ double used_fraction = ReadMultiXactMemberCount() / (double) MaxMultiXactOffset;
+ // TODO: change this to consider the offset SLRU size as well, as described by Robert?
+ double scale_factor =
+ (excessive_fraction - used_fraction) / (excessive_fraction - safe_fraction);
+ scale_factor = Min(Max(scale_factor, 0.0), 1.0); /* Clamp value in range 0...1. */
+ return autovacuum_multixact_freeze_max_age * scale_factor;
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1118,7 +1146,7 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age_adjusted();
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1931,7 +1959,9 @@ do_autovacuum(void)
{
default_freeze_min_age = vacuum_freeze_min_age;
default_freeze_table_age = vacuum_freeze_table_age;
- default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
+ default_multixact_freeze_min_age =
+ Min(vacuum_multixact_freeze_min_age,
+ autovacuum_multixact_freeze_max_age_adjusted());
default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
}
@@ -2684,8 +2714,8 @@ relation_needs_vacanalyze(Oid relid,
: autovacuum_freeze_max_age;
multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age >= 0)
- ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
- : autovacuum_multixact_freeze_max_age;
+ ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age_adjusted())
+ : autovacuum_multixact_freeze_max_age_adjusted();
av_enabled = (relopts ? relopts->enabled : true);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..c4afbc2 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern MultiXactOffset ReadMultiXactMemberCount(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..71931ef 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int autovacuum_multixact_freeze_max_age_adjusted(void);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
memberswrap-2-incremental.patch (application/octet-stream, 8.0K) download
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 03ca079..4ac3d69 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -908,6 +908,41 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
}
/*
+ * Check if we could add "distance" to "start", without moving past
+ * "boundary", using modulo arithmetic.
+ */
+static bool
+MultiXactOffsetWouldWrap(MultiXactOffset boundary,
+ MultiXactOffset start,
+ int distance)
+{
+ MultiXactOffset finish = start + distance;
+ Assert(distance >= 0);
+ if (start < boundary)
+ /*------------------------------------------------------------
+ *
+ * <----S----B---->
+ *
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [---) = F OK
+ * [----] = F wrapped past B
+ *------------------------------------------------------------
+ */
+ return finish >= boundary || finish < start;
+ else
+ /*------------------------------------------------------------
+ *
+ * <----B----S---->
+ *
+ * [---) = F OK
+ * [---) = F wrapped past B (and UINT_MAX)
+ * [----] = F OK
+ *------------------------------------------------------------
+ */
+ return finish >= boundary && finish < start;
+}
+
+/*
* GetNewMultiXactId
* Get the next MultiXactId.
*
@@ -1063,13 +1098,13 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* multixact freeze settings would have to be reduced for that to have any
* effect, and we can't do that from here.
*/
- if (MultiXactOffsetPrecedes(MultiXactState->offsetStopLimit, nextOffset + nmembers))
+ if (MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit, nextOffset, nmembers))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("database is not accepting commands that generate new MultiXactIds to avoid \"members\" wraparound data loss in database with OID %u",
MultiXactState->oldestMultiXactDB),
errhint("Execute a database-wide VACUUM in that database, with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
- else if (MultiXactOffsetPrecedes(MultiXactState->offsetWarnLimit, nextOffset + nmembers))
+ else if (MultiXactOffsetWouldWrap(MultiXactState->offsetWarnLimit, nextOffset, nmembers))
ereport(WARNING,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg_plural("database with OID %u must be vacuumed before %d more multixact member is used",
@@ -2513,6 +2548,29 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
}
/*
+ * Returns an instantaneous snapshot of the current number of members in the
+ * members SLRU area.
+ */
+MultiXactOffset
+ReadMultiXactMemberCount(void)
+{
+ MultiXactOffset nextOffset;
+ MultiXactOffset oldestOffset;
+ MultiXactId oldestMultiXactId;
+
+ LWLockAcquire(MultiXactGenLock, LW_SHARED);
+ nextOffset = MultiXactState->nextOffset;
+ oldestMultiXactId = MultiXactState->oldestMultiXactId;
+ LWLockRelease(MultiXactGenLock);
+ /*
+ * TODO: In future, could oldestMultiXactMemberOffset be stored in shmem,
+ * pg_controdata, alongside oldestMultiXactId?
+ */
+ oldestOffset = read_offset_for_multi(oldestMultiXactId);
+ return nextOffset - oldestOffset;
+}
+
+/*
* SlruScanDirectory callback.
* This callback deletes segments that are outside the range determined by
* the given page numbers.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ead161..3502a7f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -601,7 +601,7 @@ vacuum_set_xid_limits(Relation rel,
if (freezetable < 0)
freezetable = vacuum_multixact_freeze_table_age;
freezetable = Min(freezetable,
- autovacuum_multixact_freeze_max_age * 0.95);
+ autovacuum_multixact_freeze_max_age_adjusted() * 0.95);
Assert(freezetable >= 0);
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be4cd1d..071d492 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1052,6 +1052,34 @@ db_comparator(const void *a, const void *b)
}
/*
+ * Returns vacuum_multixact_freeze_max_age, adjusted down to prevent excessive use
+ * of addressable multixact member space if required.
+ *
+ * The goal is to avoid the situation where new multixacts can't be created
+ * because the offsets used to address pg_multixact/members would wrap around.
+ *
+ * If less than "safe fraction" of the total available member space is used,
+ * then we make no adjustment. If more than the "excessive fraction" of the
+ * total available member space is used, then we use a freeze max age of zero
+ * to trigger aggressive vacuuming. In between, we scale the given freeze max
+ * age down linearly, so that vacuuming becomes more aggressive as the member
+ * SLRU grows.
+ */
+int
+autovacuum_multixact_freeze_max_age_adjusted()
+{
+ // TODO: where to get these constants?
+ const double safe_fraction = 0.25;
+ const double excessive_fraction = 0.75;
+ double used_fraction = ReadMultiXactMemberCount() / (double) MaxMultiXactOffset;
+ // TODO: change this to consider the offset SLRU size as well, as described by Robert?
+ double scale_factor =
+ (excessive_fraction - used_fraction) / (excessive_fraction - safe_fraction);
+ scale_factor = Min(Max(scale_factor, 0.0), 1.0); /* Clamp value in range 0...1. */
+ return autovacuum_multixact_freeze_max_age * scale_factor;
+}
+
+/*
* do_start_worker
*
* Bare-bones procedure for starting an autovacuum worker from the launcher.
@@ -1118,7 +1146,7 @@ do_start_worker(void)
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age;
+ multiForceLimit = recentMulti - autovacuum_multixact_freeze_max_age_adjusted();
if (multiForceLimit < FirstMultiXactId)
multiForceLimit -= FirstMultiXactId;
@@ -1931,7 +1959,9 @@ do_autovacuum(void)
{
default_freeze_min_age = vacuum_freeze_min_age;
default_freeze_table_age = vacuum_freeze_table_age;
- default_multixact_freeze_min_age = vacuum_multixact_freeze_min_age;
+ default_multixact_freeze_min_age =
+ Min(vacuum_multixact_freeze_min_age,
+ autovacuum_multixact_freeze_max_age_adjusted());
default_multixact_freeze_table_age = vacuum_multixact_freeze_table_age;
}
@@ -2684,8 +2714,8 @@ relation_needs_vacanalyze(Oid relid,
: autovacuum_freeze_max_age;
multixact_freeze_max_age = (relopts && relopts->multixact_freeze_max_age >= 0)
- ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age)
- : autovacuum_multixact_freeze_max_age;
+ ? Min(relopts->multixact_freeze_max_age, autovacuum_multixact_freeze_max_age_adjusted())
+ : autovacuum_multixact_freeze_max_age_adjusted();
av_enabled = (relopts ? relopts->enabled : true);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 640b198..c4afbc2 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -126,6 +126,7 @@ extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
extern void MultiXactSetSafeTruncate(MultiXactId safeTruncateMulti);
+extern MultiXactOffset ReadMultiXactMemberCount(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 6eaaf4c..71931ef 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -53,6 +53,8 @@ extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void);
+extern int autovacuum_multixact_freeze_max_age_adjusted(void);
+
#ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-24 13:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:59 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-27 20:11 ` David Gould <daveg@sonic.net>
1 sibling, 0 replies; 113+ messages in thread
From: David Gould @ 2015-04-27 20:11 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Thomas Munro <thomas.munro@enterprisedb.com>; Kevin Grittner <kgrittn@ymail.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Mon, 27 Apr 2015 11:59:10 -0300
Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> I think we can easily determine the rate of multixact member space
> consumption and compare to the rate of multixact ID consumption;
> considering the historical multixact size (number of members per
> multixact) it would be possible to change the freeze ages by the same
> fraction, so that autovac effectively behaves as if the members
> consumption rate is what is driving the freezing instead of ID
> consumption rate. That way, we don't have to jump suddenly from
> "normal" to "emergency" behavior as some fixed threshold.
I would like to add a data point: one of my clients has a plpgsql function
that manages to use ten to 30 thousand multixact ids per invocation. It
interacts with a remote resource and sets an exception handler on a per
item basis to catch errors on the remote call.
-dg
--
David Gould 510 282 0869 daveg@sonic.net
If simplicity worked, the world would be overrun with insects.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-24 21:34 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-27 14:46 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
1 sibling, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-04-24 21:34 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; thomas.munro@enterprisedb.com <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas <robertmhaas@gmail.com> wrote:
> On Tue, Apr 21, 2015 at 5:16 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
>> Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>> Here's a patch. I have tested locally and it closes the issue
>>> for me. If those affected can confirm that it stops the file
>>> removal from happening, I'd appreciate it.
>>
>> Based on initial testing, it seems to stop file removal from
>> happening rather too well. Before applying the patch I ran a test
>> test that generated files 0000 to 1185D in the members directory.
>> Even setting vacuum_multixact_freeze_min_age and
>> vacuum_multixact_freeze_table_age very low, none of the members
>> files would go away with VACUUM (with and without FREEZE) followed
>> by CHECKPOINT. After applying the patch and starting with a fresh
>> initdb, with very low settings of the vacuum_multixact_* GUCs I get
>> the new error almost immediately, while the only file in the
>> members subdirectory is 0000 and it is 8kB in size.
>>
>> I think the calculations might be wrong, but I'm not sure what does
>> make sense.
> Can anyone else reproduce this?
I think I see why I was seeing this and nobody else was -- I was
testing the cleanup on an otherwise quiescent cluster. It seems
that no amount of VACUUM and CHECKPOINT will clean up the members
subdirectory in the absence of processes adding more members. But
after performing the VACUUMs and CHECKPOINT if I start the test
program to add more multi-transactions with lots of members, *then*
the members subdirectory gets cleaned up. That seems confusing and
a bit annoying, but is otherwise benign. I would put "allow VACUUM
followed by CHECKPOINT to delete unneeded files from the members
subdirectory" on the "nice to have" list, but would not want to
delay a fix for the corruption issues for it.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 21:34 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-04-27 14:46 ` Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:57 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
0 siblings, 1 reply; 113+ messages in thread
From: Robert Haas @ 2015-04-27 14:46 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; +Cc: thomas.munro@enterprisedb.com <thomas.munro@enterprisedb.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
On Fri, Apr 24, 2015 at 5:34 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
> I think I see why I was seeing this and nobody else was
Thomas said he reproduced it. No?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 21:34 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-27 14:46 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
@ 2015-04-27 14:57 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-27 15:24 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 113+ messages in thread
From: Kevin Grittner @ 2015-04-27 14:57 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: thomas.munro@enterprisedb.com <thomas.munro@enterprisedb.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
Robert Haas <robertmhaas@gmail.com> wrote:
> On Fri, Apr 24, 2015 at 5:34 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
>> I think I see why I was seeing this and nobody else was
>
> Thomas said he reproduced it. No?
I should have been more clear about what I meant by "this". Thomas
said he reproduced the immediate errors with Álvaro's patch, but if
he said anything about files in the members subdirectory not going
away with VACUUM followed by CHECKPOINT, regardless of
configuration, I missed it. It turns out that these steps only
"prime the pump" for the files to be deleted on subsequent access
to the members SLRU. That doesn't contribute to database
corruption, but it sure can be confusing for someone trying to
clean things up.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
* Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-13 21:08 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-20 19:04 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 21:16 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-24 21:34 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
2015-04-27 14:46 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:57 ` Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) Kevin Grittner <kgrittn@ymail.com>
@ 2015-04-27 15:24 ` Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 113+ messages in thread
From: Alvaro Herrera @ 2015-04-27 15:24 UTC (permalink / raw)
To: Kevin Grittner <kgrittn@ymail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; thomas.munro@enterprisedb.com <thomas.munro@enterprisedb.com>; tgarnett@panjiva.com <tgarnett@panjiva.com>; pgsql-bugs
Kevin Grittner wrote:
> Robert Haas <robertmhaas@gmail.com> wrote:
> > On Fri, Apr 24, 2015 at 5:34 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
> >> I think I see why I was seeing this and nobody else was
> >
> > Thomas said he reproduced it. No?
>
> I should have been more clear about what I meant by "this". Thomas
> said he reproduced the immediate errors with Álvaro's patch, but if
> he said anything about files in the members subdirectory not going
> away with VACUUM followed by CHECKPOINT, regardless of
> configuration, I missed it. It turns out that these steps only
> "prime the pump" for the files to be deleted on subsequent access
> to the members SLRU. That doesn't contribute to database
> corruption, but it sure can be confusing for someone trying to
> clean things up.
The whole matter of truncating multixact is a longish trip. It starts
when autovacuum completes a round or VACUUM finishes processing a table;
these things call vac_update_datfrozenxid. That routine scans pg_class
and sees if datfrozenxid or datminmxid can be advanced from their
current points; only if any of these can, vac_truncate_clog is called.
That routine calls SetMultiXactIdLimit(), which determines a new
MultiXactState->oldestMultiXactId (saved in shared memory). The
involvement of vacuum stops here; following steps happen at checkpoint.
At checkpoint, oldestMultiXactId is saved to pg_control as part of a
checkpoint (MultiXactGetCheckptMulti); the checkpointed value is passed
back to multixact by MultiXactSetSafeTruncate, which saves it in shmem
as lastCheckpointedOldest. The same checkpoint later calls
TruncateMultiXact which can remove files.
Note that if vac_update_datfrozenxid finds that the pg_database values
cannot be changed (during the vacuum phase), the multixact truncation
point is not advanced and checkpoint has nothing to do. But note that
the clog counter advancing enough will also trigger multixact
truncation.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 113+ messages in thread
end of thread, other threads:[~2015-05-11 15:00 UTC | newest]
Thread overview: 113+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 19:21 BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated) tgarnett@panjiva.com
2015-04-07 21:53 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-07 22:06 ` Timothy Garnett <tgarnett@panjiva.com>
2015-04-08 12:32 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-08 13:25 ` Timothy Garnett <tgarnett@panjiva.com>
2015-04-08 18:43 ` Bruce Momjian <bruce@momjian.us>
2015-04-13 21:08 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-15 16:04 ` Robert Haas <robertmhaas@gmail.com>
2015-04-16 20:33 ` Timothy Garnett <tgarnett@panjiva.com>
2015-04-20 19:04 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-21 00:25 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-23 05:25 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 06:23 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 06:30 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-28 14:35 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-29 00:14 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-29 11:41 ` Amit Kapila <amit.kapila16@gmail.com>
2015-04-30 05:17 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 10:51 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-01 19:08 ` Robert Haas <robertmhaas@gmail.com>
2015-05-02 06:16 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-03 04:40 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-03 23:49 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 06:25 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 07:12 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 11:49 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 06:47 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-04 19:06 ` Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:37 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 20:59 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 21:30 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-05 03:56 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-05 04:11 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 18:46 ` Robert Haas <robertmhaas@gmail.com>
2015-05-02 11:22 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 19:01 ` Robert Haas <robertmhaas@gmail.com>
2015-05-04 20:41 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-05 07:58 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 21:26 ` Robert Haas <robertmhaas@gmail.com>
2015-05-05 21:46 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 22:36 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-06 02:08 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 01:43 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 01:53 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 02:29 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 10:26 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-06 10:45 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 13:32 ` Robert Haas <robertmhaas@gmail.com>
2015-05-06 14:17 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 14:34 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-06 16:15 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-06 16:23 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 01:48 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 02:44 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 04:23 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 14:02 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-07 15:05 ` Kevin Grittner <kgrittn@ymail.com>
2015-05-07 15:04 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 15:18 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 15:30 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 16:39 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:00 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 18:32 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 18:39 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-07 22:21 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-07 23:58 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 06:25 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 23:41 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 01:55 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-09 02:46 ` Robert Haas <robertmhaas@gmail.com>
2015-05-09 12:00 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-09 12:43 ` Robert Haas <robertmhaas@gmail.com>
2015-05-09 21:41 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 02:45 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 11:56 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-11 15:00 ` Robert Haas <robertmhaas@gmail.com>
2015-05-11 02:05 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 05:17 ` Robert Haas <robertmhaas@gmail.com>
2015-05-07 20:32 ` Robert Haas <robertmhaas@gmail.com>
2015-05-08 04:26 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-08 06:00 ` Michael Paquier <michael.paquier@gmail.com>
2015-05-06 13:18 ` Amit Kapila <amit.kapila16@gmail.com>
2015-05-04 20:36 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-05-04 22:51 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-05-05 01:03 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 14:33 ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:34 ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 14:56 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 16:04 ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 17:54 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 18:13 ` Jeff Janes <jeff.janes@gmail.com>
2015-04-28 18:52 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-28 23:13 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-29 17:07 ` Jeff Janes <jeff.janes@gmail.com>
2015-04-30 17:03 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-30 13:02 ` Robert Haas <robertmhaas@gmail.com>
2015-04-30 16:51 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-30 03:52 ` Amit Kapila <amit.kapila16@gmail.com>
2015-04-21 05:12 ` Amit Kapila <amit.kapila16@gmail.com>
2015-04-29 06:10 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-21 21:16 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-23 17:18 ` Robert Haas <robertmhaas@gmail.com>
2015-04-24 00:14 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-24 01:59 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-24 13:18 ` Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:59 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-27 16:40 ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 00:19 ` Thomas Munro <thomas.munro@enterprisedb.com>
2015-04-27 20:11 ` David Gould <daveg@sonic.net>
2015-04-24 21:34 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-27 14:46 ` Robert Haas <robertmhaas@gmail.com>
2015-04-27 14:57 ` Kevin Grittner <kgrittn@ymail.com>
2015-04-27 15:24 ` Alvaro Herrera <alvherre@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox