Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTRud-00079E-O4 for pgsql-general@arkaria.postgresql.org; Thu, 14 Jun 2018 13:03:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTRuc-0001Nd-HX for pgsql-general@arkaria.postgresql.org; Thu, 14 Jun 2018 13:03:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTRuc-0001NS-8L for pgsql-general@lists.postgresql.org; Thu, 14 Jun 2018 13:03:38 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fTRuY-0005eY-Gg for pgsql-general@postgresql.org; Thu, 14 Jun 2018 13:03:37 +0000 Received: by mail-wm0-x242.google.com with SMTP id v131-v6so11865462wma.1 for ; Thu, 14 Jun 2018 06:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=cllpM6DrMVNxTqTX41WW16oFD37ik+5+md0WXN2iCbc=; b=EpKdnA+wvUpBKNySjsmJ1nxfIXPJQaeoOYFnmpXx+KYJDvekGtaTEkDdQ5QroFnXVE OoP0uysmSz7nbALKt0B44xVA1lc/AJshw47Br/AWMoh9/KTzrWuxHfl1vt8FGsx3efC0 NNQbAi4OzKJsbeDjnKbPdN0MtlHJpwZTClWFuPtrQj+BWPcYYAKUfPSa3upz9FXDR4Ns KPRrYXGLcY8bQIUypzyufJvAM38cEet4Z2NNRd2tBsH2Z/xJxN31nibt7lqNMdy8X8QQ zgDlRvcBagoKEykfcqi/qcVaBJOIz7B60npQUw21ufOa6GjyeSGOy2+pGI6mYOjMjgN7 Eo7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=cllpM6DrMVNxTqTX41WW16oFD37ik+5+md0WXN2iCbc=; b=q2TYclWuMTxYuxqnaME75AJVJ93zHGdm+63Q69L6Q+SkJPZ9yYHEU+11dnUWgyD/Gx mtiiFyufaqs4aAUmatnW0XJz7HMdgV/kJSHrw8hgSPMsmb0l+O+w3HTn2iLA0GnB5OJc Nfmp6mWFDLCJ5iyqaU20rexOe6oirv/LIB0rtaVk9KKg5PrOAqkF3k3+cvOeQmAV24bk DL8WuOMdhHfakDC9ipZ9y/rfnhXfIjfy/zXlsGh0hFXE9G2oR3NiCun0ALvjpiRGz8n2 YnRDlaYf7PQ1CDtEg8Jp5cUPp3pJ1EBE2EZGhT5tcdNXjawT9QRxVl0HOS6vWPuDguwC 7BZg== X-Gm-Message-State: APt69E0mHDlTN/EuhAJjWeh8Ak92ozgkSS3KCZFOP24kloWVoacg6V3Y bKVka1RLaqRFMtMar/XSzaI= X-Google-Smtp-Source: ADUXVKLQaHjdlKd3rBtBU/HWX8IMZbLCQS1Tkya2h0p3ccSSLtS0egJkJ70iMX+Vn3D7m8VEn8+Lpg== X-Received: by 2002:a50:9f6b:: with SMTP id b98-v6mr2645727edf.219.1528981412630; Thu, 14 Jun 2018 06:03:32 -0700 (PDT) Received: from [192.168.3.84] ([217.138.59.34]) by smtp.gmail.com with ESMTPSA id y22-v6sm2254705edm.95.2018.06.14.06.03.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 06:03:32 -0700 (PDT) From: Lawrence Jones Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_1D2D464C-9913-4E43-ACB5-818D2143FF65" Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Subject: Re: Impact of multixact "members" limit exceeded Date: Thu, 14 Jun 2018 14:03:30 +0100 In-Reply-To: Cc: Alvaro Herrera , pgsql-general@postgresql.org To: Daniel Lagerman References: <20180614032901.wn5xfnizfxnj2q7t@alvherre.pgsql> X-Mailer: Apple Mail (2.3445.4.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_1D2D464C-9913-4E43-ACB5-818D2143FF65 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hey Daniel, This may be entirely unrelated to your query, but we=E2=80=99ve = previously experienced issues with 9.4 and crazy multixact members = growth. After digging into the issue, we found the culprit was code that would = perform the following actions: begin; for query in many_queries: savepoint ; select * from table where id=3D=E2=80=98myid' for update; update table increment(counter) where id=3D=E2=80=98myid'; release savepoint; commit; While I found it very difficult to find documentation on the purpose of = multixacts, and I=E2=80=99m certain to have critical misunderstandings = around their workings, it seemed that Postgres was inferring each new = savepoint as a new potential transaction that would lock the given row, = and each of those transactions needed to be added to the on-going = multixact members list. The members list (I believe) is immutable, and adding a new member = requires construction of a new members list, and so your multixact = members offset will grow quadratically with the number of times you lock = your row. Where we were locking repeatedly in a large loop, we were = seeing huge multixact members growth that would trigger the override for = multixact vacuums, regardless of disabling or configuring your = autovacuum. If you=E2=80=99re continually seeing multixact members growth that = outpaces your vacuums, then I suggest having a scan for the above usage = pattern, or alternatively upgrading. We couldn=E2=80=99t replicate the = growth in 9.5 and above, as presumably newer Postgres versions correctly = no-op when a transaction tries locking a row when its parent is already = present in the multixact. This comes with the disclaimer of a Postgres amateur, it simply seemed = relevant to your situation. Lawrence > On 14 Jun 2018, at 04:47, Daniel Lagerman wrote: >=20 > Hello =C3=81lvaro, >=20 > I'm running at 9.4.3, I know its an older version but upgrading it = outside the scope right now for various reasons. > Based on the settings I posted what would be your recommended settings = right now to resolve this situation? >=20 > Maintenance is limited to weekends as this is a database which needs = to be online 24/5 and consumes a lot of data and responds to many = queries. >=20 > I very much appreciate the recommendation but I would also like to now = the impact of this warning, data right now does not seem to be = corrupted, get overwritten, for that matter not insert new data or cause = issues when read. It just seems that is has stopped creating "members" = and I can't read into what problem that would cause, table was around = 1.6 TB, it was cleaned up and the re-packed using pg-repack to go down = to around 400 GB in size, however a freeze vacuum or autovacuum did not = complete. >=20 > Then when it comes to vacuum, do you think its worth increasing = work_mem to say 200 GB, for the maintenance period only, and let = autovacuum go to town on the tables with the highest age and lowest = minmixid? Or should one run for example flexible freeze instead with = zero pauses as nothing is happening on the weekends, which means no = inbound transactions. Also worth mentioning is thatI restart the server = on the weekend after I have backed up the data. >=20 > I have tried running autovacuum for 40 hours before with 5 GB = work_mem, on the weekend, across 6 tables at the same time and it never = completed on the bigger tables which are around 2 TB. >=20 > Best regards=20 >=20 > Daniel >=20 >=20 > On Wed, Jun 13, 2018 at 11:29 PM, Alvaro Herrera = > wrote: > On 2018-Jun-13, Daniel Lagerman wrote: >=20 > > Hello! > >=20 > > I have a question where I'm trying to determine the seriousness of = the > > problem. >=20 > What's your server version? >=20 > The way to reclaim members space is to move forwards the > pg_database.datminmxid value from the database where it is oldest; and > the way to move *that* forward is to advance the pg_class.relminmxid > value from the tables in which it is oldest. So you need to set a low > value vacuum_multixact_freeze_min_age and _table_age and vacuum those > tables. >=20 > --=20 > =C3=81lvaro Herrera https://www.2ndQuadrant.com/ = > PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services >=20 --Apple-Mail=_1D2D464C-9913-4E43-ACB5-818D2143FF65 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hey = Daniel,

This may be = entirely unrelated to your query, but we=E2=80=99ve previously = experienced issues with 9.4 and crazy multixact members = growth.

After = digging into the issue, we found the culprit was code that would perform = the following actions:

begin;
for query in = many_queries:
  savepoint <x>;
  select * from table where id=3D=E2=80=98= myid' for update;
  update table increment(counter) where = id=3D=E2=80=98myid';
  release savepoint;
commit;

While I found it very difficult to find = documentation on the purpose of multixacts, and I=E2=80=99m certain to = have critical misunderstandings around their workings, it seemed that = Postgres was inferring each new savepoint as a new potential transaction = that would lock the given row, and each of those transactions needed to = be added to the on-going multixact members list.

The members list (I believe) is = immutable, and adding a new member requires construction of a new = members list, and so your multixact members offset will grow = quadratically with the number of times you lock your row. Where we were = locking repeatedly in a large loop, we were seeing huge multixact = members growth that would trigger the override for multixact vacuums, = regardless of disabling or configuring your autovacuum.

If you=E2=80=99re = continually seeing multixact members growth that outpaces your vacuums, = then I suggest having a scan for the above usage pattern, or = alternatively upgrading. We couldn=E2=80=99t replicate the growth in 9.5 = and above, as presumably newer Postgres versions correctly no-op when a = transaction tries locking a row when its parent is already present in = the multixact.

This comes with the disclaimer of a Postgres amateur, it = simply seemed relevant to your situation.

Lawrence


On 14 Jun 2018, at 04:47, Daniel Lagerman <spjheruur@gmail.com>= wrote:

Hello=20 =C3=81lvaro,

I'm= running at 9.4.3, I know its an older version but upgrading it outside = the scope right now for various reasons.
Based on = the settings I posted what would be your recommended settings right now = to resolve this situation?

Maintenance is limited to weekends as this is a database = which needs to be online 24/5 and consumes a lot of data and responds to = many queries.

I = very much appreciate the recommendation but I would also like to now the = impact of this warning, data right now does not seem to be corrupted, = get overwritten, for that matter not insert new data or cause issues = when read. It just seems that is has stopped creating "members" and I = can't read into what problem that would cause, table was around 1.6 TB, = it was cleaned up and the re-packed using pg-repack to go down to around = 400 GB in size, however a freeze vacuum or autovacuum did not = complete.

Then when it comes to vacuum, do you think its worth = increasing work_mem to say 200 GB, for the maintenance period only, and = let autovacuum  go to town on the tables with the highest age and = lowest minmixid? Or should one run for example flexible freeze instead = with zero pauses as nothing is happening on the weekends, which means no = inbound transactions. Also worth mentioning is thatI restart the server = on the weekend after I have backed up the data.

I have tried running autovacuum for 40 = hours before with 5 GB work_mem, on the weekend, across 6 tables at the = same time and it never completed on the bigger tables which are around 2 = TB.

Best = regards

Daniel


On Wed, Jun 13, 2018 at 11:29 PM, Alvaro Herrera = <alvherre@2ndquadrant.com> wrote:
On = 2018-Jun-13, Daniel Lagerman wrote:

> Hello!
>
> I have a question where I'm trying to determine the seriousness of = the
> problem.

What's your server version?

The way to reclaim members space is to move forwards the
pg_database.datminmxid value from the database where it is oldest; = and
the way to move *that* forward is to advance the pg_class.relminmxid
value from the tables in which it is oldest.  So you need to set a = low
value vacuum_multixact_freeze_min_age and _table_age and = vacuum those
tables.

--
=C3=81lvaro Herrera              =   https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & = Services


= --Apple-Mail=_1D2D464C-9913-4E43-ACB5-818D2143FF65--