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 1tvCYI-001wAw-KP for pgsql-performance@arkaria.postgresql.org; Thu, 20 Mar 2025 09:51:02 +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 1tvCXJ-001FTH-EZ for pgsql-performance@arkaria.postgresql.org; Thu, 20 Mar 2025 09:50:01 +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 1tuyRT-00A157-QJ for pgsql-performance@lists.postgresql.org; Wed, 19 Mar 2025 18:47:03 +0000 Received: from mout.gmx.net ([212.227.17.20]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tuyRR-003qif-19 for pgsql-performance@lists.postgresql.org; Wed, 19 Mar 2025 18:47:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1742410019; x=1743014819; i=jimis@gmx.net; bh=RQCTyW+ciKrbyVza96eC40/UhPEqoQLGFyErrD3puDg=; h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=XQzETpDq2OcbjHmj0PV/yj53l94JObZKy6mDvwad44eV48DiwUUnsUKags8V5mtV DnpOONz1Rt8Wz6aVBj7W3tgEaUjGJyZbEoUIAiJ3LxTl5Ac8ORqztZtbM8VQrveAp MbVIEMl/NpvAl+hmObaIjV9Mh85qoqirVLL9JA24yyKFXwNhc7X5rsW1B3QdN+uWx pJO2SAGUX99K0WrtBfgbDOA9By993OylRpke2LP4CzoRlgipEneIZdZ5NDqALDp2d 4eAXnvO1Idwf8wwNrwpelklBZMR0CcItr5gGncL8vdNrq+Euhk4k6DvgMaRNjdvvj 20VnYkqWxid+vr0kfQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.9.70.81] ([185.55.106.54]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M2O2Q-1ttL5B11nq-009gHK for ; Wed, 19 Mar 2025 19:46:59 +0100 Date: Wed, 19 Mar 2025 19:46:58 +0100 (CET) From: Dimitrios Apostolou To: pgsql-performance@lists.postgresql.org Subject: parallel pg_restore blocks on heavy random read I/O on all children processes Message-ID: <6bd16bdb-aa5e-0512-739d-b84100596035@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Provags-ID: V03:K1:B/w2V7WBfVtlVemYW9KL8eJbyDkTFM+QktgNNS83ZBmjNj661I/ guLQY2h3a6d7v4+nE/6UzSbi4KIZITvGq+UgjxXGj3HOke7oPHXczQd0X/bhJ5UaFCi4qOg DWKRlGPoGL1SIz9YJvsKxuYBQtpa09Esl9kNxHlO0CNvo870G0PMCHMKMBMsqMLvMV6C0SA MeiFYwICsjIV4kspfsJYw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:wl9ZHwcqvjI=;OKWl93lNIexc2FCZoOV0sXyM9gg g1daNWfb78coIBvVxK3AuIDvK+yspN3VnYNrI9jeAbUXipkmYrBn7OD1S2UmeXCpYAH/izTdA Rbss1pDxndNE+4y7ouMuShqZp1BFbaeOAaO+br6S04h9Q5fSbV9L45Xhhy+oKi/DC/1K+TfYP u5Um6IMj4kQjDGOsKnOMkoNWPES3smV3Py4rQOzx+hZhFKIBSYhZWDBhMA4KMgMW/P+ya6nv4 u31tHyuH+Utpfcz57rrbe1g3cnF5Ln6ArqRR430hdMs0TzGrzV03R2ITmydvyDoOlzfVU51cs tjfI8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 MDCXNkir+iZQJ1aNkA0fZU6sFUVea5QuUunPXwZ/vHKD1+lcwydPHICi2meCSKybtgjkBRDG/ RRXXp1g== Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello list, I noticed the weird behaviour that doing a pg_restore of a huge database dump, leads to constant read I/O (at about 15K IOPS from the NVMe drive that has the dump file) for about one hour. I believe it happens with any -j value>=3D2. In particular, I get output like the following in the pg_restore log, only a few seconds after running it: pg_restore: launching item 12110 TABLE DATA yyy pg_restore: processing data for table "public.yyy" [ long pause ...] pg_restore: finished item 12110 TABLE DATA yyy The output varies a bit, depending on when each process comes to the bottleneck point, and it is hard to isolate each process' log since the output is not prefixed with the PID, so take it with a grain of salt. If I strace the pg_restore children, I see them read()ing 4K and seek()ing a couple blocks forward, all the time: read(4, "..."..., 4096) =3D 4096 lseek(4, 55544369152, SEEK_SET) =3D 55544369152 read(4, "..."..., 4096) =3D 4096 lseek(4, 55544381440, SEEK_SET) =3D 55544381440 read(4, "..."..., 4096) =3D 4096 lseek(4, 55544397824, SEEK_SET) =3D 55544397824 read(4, "..."..., 4096) =3D 4096 lseek(4, 55544414208, SEEK_SET) =3D 55544414208 read(4, "..."..., 4096) =3D 4096 lseek(4, 55544426496, SEEK_SET) =3D 55544426496 No other syscalls are occuring (no sends or writes whatsoever). After the ~1h pause, I don't notice the behaviour again during the many hours restore, even though there are plenty of larger tables in the dump. The normal restore activity resumes, during which the pg_restore processes are barely noticeable in the system, and the COPY postgres backend processes do most of the work. Here is the exact pg_restore command that reproduced the issue for me last on PostgreSQL 17: pg_restore -vvv -U $DBUSER -j8 -d $DBNAME --data-only --no-tablespaces --= no-table-access-method --strict-names $DUMP_FILENAME And here is the pg_dump command which has created the dump file, executed on PostgreSQL 16. pg_dump -v --format=3Dcustom --compress=3Dzstd --no-toast-compression $DB= NAME | $send_to_remote_storage The database is multiple TBs large with a couple thousands tables (notable is one huge table with 1000 partitions). The zstd-compressed custom format dump file is 816 GB in size. What do you think causes this? Is it something that can be improved? Thanks in advance, Dimitris