Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sZE2u-00HAGL-DV for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2024 18:27:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sZE2r-00Bcca-SG for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2024 18:27:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sZE2r-00BccS-B6 for pgsql-general@lists.postgresql.org; Wed, 31 Jul 2024 18:27:29 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sZE2o-002Q5Q-AJ for pgsql-general@lists.postgresql.org; Wed, 31 Jul 2024 18:27:28 +0000 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-81f96eaa00fso240028839f.1 for ; Wed, 31 Jul 2024 11:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilm.com; s=google; t=1722450445; x=1723055245; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=nTtzk70oJWwt6ql+eAIwRbXNgVfGlubIb5hsKUVhf4g=; b=Xiqi1NSkVJXcg85rf6xRlGcgOzFPs40aPo9VGqdpCPmqd1ktkA4dakRhgQ5M+j/m6j FlEyHCpmf9Q1k8kbjaAuZBdzhDI/xE11snTbLgAggJKJYPoMCiLeWBO/9swjWGfbJBLB nKbXu/IiwGRzZLe94OkM27Lg1fcbdNI5JgVXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722450445; x=1723055245; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nTtzk70oJWwt6ql+eAIwRbXNgVfGlubIb5hsKUVhf4g=; b=dkMTGmDXlOEeowADcCISb+oGn63UjT53rtJkb0REn5OGX5zmneswIymoPjXVhHNJuK TpMM5fxOE13yb1mH7A9ImjoW1MfxBszT63Ma57E64bXcHL00GZWsKoLMg1F0WfBwYT/0 yQkAum9dNND/GsUuGcIh2qpWtTAFK2cBc7GyK50yOVsaU/hRmGBjSbSJHqHxHON3gzqy HX53ZI6tNUhdUv5b/FFqbtMa/TzimvLjmS+qISgSnYbbVx86v1kjkau5bgX5eabkhaM8 sFnLVrOGivYGkyWtAGoT8od/n+WUqF7/Ym5NkFJ/hlp4gR6qy+SY3BV8enC2mKVruDKc ykIg== X-Gm-Message-State: AOJu0YyZ18E3Uwdpe9dQY2dcQvvk7SXh9SL8GxM1RvDn0n2I2Kv0EkHn +ybbAnWfTL5bc+CxnFcUkLB5YnZyI8EfAjYY4B67B9QHb7BefgESCCZgovW2cBZVOXo+8Vq7ors 0JnSOAJ9CN+/upoZcPs+OuNTgvDgmoGJOJkwobq/yGtbWCMif X-Google-Smtp-Source: AGHT+IHSda7ycvBu15AT4vi50YvlxfP5wRdjHYyRPhQjVwhULPdaS4tbKtqWLIP+0BhoqplXf0DoZrO/n7jl8kMXDNM= X-Received: by 2002:a05:6602:6116:b0:81e:23e8:8d4 with SMTP id ca18e2360f4ac-81fcc23d7eemr16481939f.6.1722450444981; Wed, 31 Jul 2024 11:27:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jim Vanns Date: Wed, 31 Jul 2024 19:27:13 +0100 Message-ID: Subject: Fwd: Suggestions to overcome 'multixact "members" limit exceeded' in temporary tables To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000eaae7e061e8f3e2f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000eaae7e061e8f3e2f Content-Type: text/plain; charset="UTF-8" (resending to general since I believe I originally sent it to hackers by mistake) I've reached the limit of my understanding and attempts at correcting my code/use of temporary tables in the face of multixact members and have come to ask for your help! Here's a brief description of my software; Pool of N connection sessions, persistent for the duration of the program lifetime. Upon each session initialisation, a set of CREATE TEMPORARY TABLE ON COMMIT DELETE ROWS statements are made for bulk ingest. Each session is acquired by a thread for use when ingesting data and therefore each temporary table remains until the session is terminated The thread performs a COPY FROM STDIN in binary format Then an INSERT INTO
SELECT FROM WHERE... This has been working great for a while and with excellent throughput. However, upon scaling up I eventually hit this error; ERROR: multixact "members" limit exceeded DETAIL: This command would create a multixact with 2 members, but the remaining space is only enough for 0 members. HINT: Execute a database-wide VACUUM in database with OID 16467 with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings. And it took me quite a while to identify that it appears to be coming from the temporary table (the other 'main' tables were being autovacuumed OK) - which makes sense because they have a long lifetime, aren't auto vacuumed and shared by transactions (in turn). I first attempted to overcome this by introducing an initial step of always creating the temporary table before the copy (and using on commit drop) but this lead to a terrible performance degradation. Next, I reverted the above and instead I introduced a VACUUM step every 1000000 (configurable) ingest operations Finally, I introduced a TRUNCATE step in addition to the occasional VACUUM since the TRUNCATE allowed the COPY option of FREEZE. The new overhead appears minimal until after several hours and again I've hit a performance degradation seemingly dominated by the TRUNCATE. My questions are; 1) Is the VACUUM necessary if I use TRUNCATE + COPY FREEZE (on the temporary table)? 2) Is there really any benefit to using FREEZE here or is it best to just VACUUM the temporary tables occasionally? 3) Is there a better way of managing all this!? Perhaps re-CREATING the TT every day or something? I understand that I can create a Linux tmpfs partition for a tablespace for the temporary tables and that may speed up the TRUNCATE but that seems like a hack and I'd rather not do it at all if it's avoidable. Thanks for your help, Jim PS. PG version in use is 15.4 if that matters here -- Jim Vanns Principal Production Engineer Industrial Light & Magic, London --000000000000eaae7e061e8f3e2f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
(resending to general sinc= e I believe I originally sent it to hackers by mistake)

I've reached the limit of my understanding and attemp= ts at correcting my code/use of temporary tables in the face of=C2=A0multix= act members and have come to ask for your help! Here's a brief descript= ion of my software;

Pool of N connection sessions, persi= stent for the duration of the program lifetime.
Upon each session= initialisation, a set of CREATE TEMPORARY TABLE ON COMMIT DELETE ROWS stat= ements are made for bulk ingest.
Each session is acquired by a th= read for use when ingesting=C2=A0data and therefore each temporary table re= mains until the session is terminated
The thread performs a COPY = <temp table> FROM STDIN in binary format
Then an INSERT INT= O <main table> SELECT FROM <temp table> WHERE...

=
This has been working great for a while and with excellent throu= ghput. However, upon scaling up I eventually hit this error;

=
ERROR: =C2=A0multixact "members" limit exceeded
DET= AIL: =C2=A0This command would create a multixact with 2 members, but the re= maining space is only enough for 0 members.
HINT: =C2=A0Execute a databa= se-wide VACUUM in database with OID 16467 with reduced vacuum_multixact_fre= eze_min_age and vacuum_multixact_freeze_table_age settings.
<= div>
And it took me quite a while to identify that it appears= to be coming from the temporary table (the other 'main' tables wer= e being autovacuumed=C2=A0OK) - which makes sense because they have a long = lifetime, aren't auto vacuumed and shared by transactions (in turn).

I first attempted to overcome this by introducing an= initial step of always creating the temporary table before the copy (and u= sing on commit drop) but this lead to a terrible performance degradation.
Next, I reverted the above and instead I introduced a VACUUM step = every 1000000 (configurable) ingest operations
Finally, I introdu= ced a TRUNCATE step in addition to the occasional VACUUM since the TRUNCATE= allowed the COPY option of FREEZE.

The new overhe= ad appears minimal until after several hours and again I've hit a perfo= rmance degradation=C2=A0seemingly dominated=C2=A0by the TRUNCATE.

My questions are;

1) Is the VACUUM= necessary if I use TRUNCATE=C2=A0+ COPY FREEZE (on the temporary table)?
2) Is there really any benefit to using FREEZE here or is it best = to just VACUUM the temporary tables occasionally?
3) Is there a b= etter way of managing all this!? Perhaps re-CREATING the TT every day or so= mething?

I understand that I can create a Linux tm= pfs partition for a tablespace for the temporary tables and that may speed = up the TRUNCATE but that seems like a hack and I'd rather not do it at = all if it's avoidable.

Thanks for your help,

Jim

PS. PG version in use = is 15.4 if that matters here

--
Jim Vanns<= br>Principal Production Engineer
Industrial Light & Magic, London
--000000000000eaae7e061e8f3e2f--