From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: pg_restore mostly idle on restoring a large number of tables
Date: Sat, 15 Jul 2023 09:51:15 -0500
Message-ID: <61c5cff7-4c28-4d40-4404-27159a05e6cc@gmail.com> (raw)
In-Reply-To: <CAEzn=HSPXi6OS-5KzGMcZeKzWKOOX1me2u2eCiGtMEZDz9Fqdg@mail.gmail.com>
References: <CAEzn=HSPXi6OS-5KzGMcZeKzWKOOX1me2u2eCiGtMEZDz9Fqdg@mail.gmail.com>
On 7/13/23 02:41, Boris Sagadin wrote:
> Hi,
>
> restoring a 1.5TB database with about 800k tables on i3.4xlarge AWS
> instace, PgSQL V12.15 on Ubuntu.
>
> Running pg_restore with -j 16, I noticed the pg_restore is busy for an
> hour or so with IO at 80%+ and then most of processes start idling and
> only a few doing some work, disk IO at 1-2%, pg_stat_activity is mostly
> idle, same goes for CPU, and this state proceeds for further 6 hours, disk
> space increases very slowly.
>
> I thought because of a lot of small tables, number of workers should be
> increased to increase parallel efficiency, so I tried with -j 128. The
> situation was somewhat better, but most of the workers start idling, again
> disk IO lowers to about 4% util, CPU util goes to about 4%, too.
>
> Stracing workers produces the perpetual read call on most pg_restore workers:
>
> # strace -p 59567
> strace: Process 59567 attached
> read(3,
>
> With only about 10 or so (out of 128) workers doing some actual work:
>
> strace -p 59367 -e sendto
> strace: Process 59367 attached
> sendto(4, "Q\0\0\0\263ALTER TABLE ONLY raw.space0"..., 180, MSG_NOSIGNAL,
> NULL, 0) = 180
> sendto(4, "Q\0\0\0.TRUNCATE TABLE ONLY raw.spa"..., 47, MSG_NOSIGNAL,
> NULL, 0) = 47
> sendto(4, "Q\0\0\0\205COPY raw.space000448117 (da"..., 134, MSG_NOSIGNAL,
> NULL, 0) = sendto(4, "Q\0\0\0\vCOMMIT\0", 12, MSG_NOSIGNAL, NULL, 0) = 12
> sendto(4, "Q\0\0\0pCREATE INDEX idx_space00044"..., 113, MSG_NOSIGNAL,
> NULL, 0) = 113
> sendto(4, "Q\0\0\0\263ALTER TABLE ONLY raw.space0"..., 180, MSG_NOSIGNAL,
> NULL, 0) = 180
> ...
> .. some lines omitted
>
> I would think that all workers would proceed with creating indexes and
> doing some useful work until the restore is finished completely?
>
> Most of the tables are very small, 2 indexes per table and without any
> foreign references etc., we have a multi tenant environment.
I always run pg_dump and pg_restore with "--verbose", and redirect stdout &
stderr to a log file. Then I "tail -f" that log file. It'll tell you what's
happening.
Also, iotop is quite useful.
--
Born in Arizona, moved to Babylonia.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: pg_restore mostly idle on restoring a large number of tables
In-Reply-To: <61c5cff7-4c28-4d40-4404-27159a05e6cc@gmail.com>
References: <CAEzn=HSPXi6OS-5KzGMcZeKzWKOOX1me2u2eCiGtMEZDz9Fqdg@mail.gmail.com> <61c5cff7-4c28-4d40-4404-27159a05e6cc@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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