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 1sVvIs-00CKyb-1f for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jul 2024 15:50:22 +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 1sVvIq-003kGA-6x for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jul 2024 15:50:20 +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 1sVvIp-003kEy-Ib for pgsql-hackers@lists.postgresql.org; Mon, 22 Jul 2024 15:50:20 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sVvIl-000t1K-Qq for pgsql-hackers@lists.postgresql.org; Mon, 22 Jul 2024 15:50:18 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-70446231242so2266664a34.1 for ; Mon, 22 Jul 2024 08:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1721663414; x=1722268214; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ROks3GL9TvvRsRxjAClvnhimzWrqU8mIVaiqQ9oEujA=; b=me6oZ7q2Bu6hAOasAQsHPtAqiuXob2uWTRMh58yihmwyoJEcMzDhtW8Se1ffENCdXD 9I5ayGb+JmR72JNAyMzJVHWoUq0oZ5HaGQRLpRH4XeI4SThGwzjDG3zr4PxBgO0UgMSM B4bY5aGuAziACBqPSLgdJKfUkYNMLQkk+Ibt7q6icIBEexzUQMaB/sXrtTW7xXt1vUBk dfPSHFZir6nfGMN97We/lGzAytk9WQyGfMqfyDQV9r0lZFIghhZQVHLspy8LlA0rQ33+ wdwQZhW7jbu1J8EyUqDbgjXf+HFHFZIOzc6CH2vI6QP9Fi6X2fmx7od2hPo/1WtFDGbE gEjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721663414; x=1722268214; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ROks3GL9TvvRsRxjAClvnhimzWrqU8mIVaiqQ9oEujA=; b=dAgsk4BJ+kOAWxQ56G6WLtRzB8t1gTD2aA7i052EBK38ZhTRDrNnJ0h0B9LjhLisqf GO4wSEdj6Rpasf9QnkIfmznDe27SFJ9UIpN00Z47ArAMx56Mkzgm+TUaNVQ36ieI3mqk l0YTRHmowyYIKxnUc6aPMN7cOHbvAjreB5xi1q/7tOH89Iil4HYS2wgdFCWrzMhSYUFY CaiVJNrgJzpBMrfhMjr6bTxedRM7Ohs8QSVLzmAMUpfV6/VA2wohPFORWPiOd4WwEIOG v9FGFRZ3/QInxEnBCrJmmIMjmsDg9LmbIZsetYIm7oXswnjc5m2RvrT1Qu4du8Yiwy9u o9oQ== X-Forwarded-Encrypted: i=1; AJvYcCXjLocYC2qAggUBXY0lWsiWMUdSXRtSqWJNVOWzPCEc17PSNSKMJc1eEkMp3LcNjvy3G/4aHZh5ys9qwix0HHlXwJ9ndXotQkEeRp4bmvnA7cWj X-Gm-Message-State: AOJu0YyhDJzNy+rRmChKbgLyJKi8F+OJcZdWDygXYS040rk0BHUTrMtr XOl2OMWUtq6qGCjEoPmFPbMCCOu/R7SfVQXg5z5/o3pkzVh5GdNeFLtsCNaiwDKZ62zdOOQgwwN 089A= X-Google-Smtp-Source: AGHT+IEqA/aLhsVEt1/R6M0uqTeaILEPDU6ltjSdv9lAC0o/AbmL4EGiIjWPp6pORTiTAkBQy8Tzkw== X-Received: by 2002:a05:6830:698e:b0:703:6845:ed89 with SMTP id 46e09a7af769-7091809843bmr182595a34.5.1721663414381; Mon, 22 Jul 2024 08:50:14 -0700 (PDT) Received: from ?IPV6:2605:a601:9180:9800::2bb? ([2605:a601:9180:9800::2bb]) by smtp.googlemail.com with ESMTPSA id d75a77b69052e-44f9cd007cesm34486861cf.21.2024.07.22.08.50.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jul 2024 08:50:13 -0700 (PDT) Message-ID: <5e3a16ad-c8e2-4695-93cb-74121c3add56@dunslane.net> Date: Mon, 22 Jul 2024 11:50:10 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Enhance pg_dump multi-threaded streaming (WAS: Re: filesystem full during vacuum - space recovery issues) To: Thomas Simpson , Scott Ribe , pgsql-hackers@lists.postgresql.org References: <7dee2c00-6184-49c5-b303-58113c1d04c6@talentstack.to> <95f5bff5-b392-4c2f-9708-8fd5547c620c@talentstack.to> <6F46CFEB-3C3A-4CEC-89DF-57D8225A5863@elevated-dev.com> <6107c011-f907-48ba-94e4-884f59c3da1a@talentstack.to> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR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PF8YGBzTIvCz/ fQoOq8AX/pE76QEuFnFZWfjw+wgBXgCVmkox2Eflkk6z4ND3pcwGZ6CfCxTQCDk/dij+2DQ4 6bmDCy/sBgcbz9mTpoLC11HLoPae6YN9nBNQRZDcEFEu54OaVOqlIdbA6m+POIBCXZdHOFc0 WoDTgxHRzC1jgQNidyd6tKqcsVJs0dzF0oKTmFFmUAqTdJO12LBuNA1rlqrR3EtpYk8B/wtS 5dIMD7Q8hwQpL+4C6GNpb6ZKnPkLi47pDOLhz2qBrqN+rqUEsT3YnExYpzj5yOBi+FlmV1Hw 49QYe1sn2ZPs In-Reply-To: <6107c011-f907-48ba-94e4-884f59c3da1a@talentstack.to> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-07-19 Fr 9:46 AM, Thomas Simpson wrote: > > Hi Scott, > > I realize some of the background was snipped on what I sent to the > hacker list, I'll try to fill in the details. > > Short background is very large database ran out of space during vacuum > full taking down the server.  There is a replica which was applying > the WALs and so it too ran out of space.  On restart after clearing > some space, the database came back up but left over the in-progress > rebuild files.  I've cleared that replica and am using it as my > rebuild target just now. > > Trying to identify the 'orphan' files and move them away always led to > the database spotting the supposedly unused files having gone and > refusing to start, so I had no successful way to clean up and get > space back. > > Last resort after discussion is pg_dumpall & reload.  I'm doing this > via a network pipe (netcat) as I do not have the vast amount of > storage necessary for the dump file to be stored (in any format). > > On 19-Jul-2024 09:26, Scott Ribe wrote: >> Do you actually have 100G networking between the nodes? Because if not, a single CPU should be able to saturate 10G. > Servers connect via 10G WAN; sending is not the issue, it's > application of the incoming stream on the destination which is > bottlenecked. >> Likewise the receiving end would need disk capable of keeping up. Which brings up the question, why not write to disk, but directly to the destination rather than write locally then copy? > In this case, it's not a local write, it's piped via netcat. >> Do you require dump-reload because of suspected corruption? That's a tough one. But if not, if the goal is just to get up and running on a new server, why not pg_basebackup, streaming replica, promote? That depends on the level of data modification activity being low enough that pg_basebackup can keep up with WAL as it's generated and apply it faster than new WAL comes in, but given that your server is currently keeping up with writing that much WAL and flushing that many changes, seems likely it would keep up as long as the network connection is fast enough. Anyway, in that scenario, you don't need to care how long pg_basebackup takes. >> >> If you do need a dump/reload because of suspected corruption, the only thing I can think of is something like doing it a table at a time--partitioning would help here, if practical. > > The basebackup is, to the best of my understanding, essentially just > copying the database files.  Since the failed vacuum has left extra > files, my expectation is these too would be copied, leaving me in the > same position I started in.  If I'm wrong, please tell me as that > would be vastly quicker - it is how I originally set up the replica > and it took only a few hours on the 10G link. > > The inability to get a clean start if I move any files out the way > leads me to be concerned for some underlying corruption/issue and the > recommendation earlier in the discussion was opt for dump/reload as > the fail-safe. > > Resigned to my fate, my thoughts were to see if there is a way to > improve the dump-reload approach for the future.  Since dump-reload is > the ultimate upgrade suggestion in the documentation, it seems > worthwhile to see if there is a way to improve the performance of that > especially as very large databases like mine are a thing with > PostgreSQL.  From a quick review of pg_dump.c (I'm no expert on it > obviously), it feels like it's already doing most of what needs done > and the addition is some sort of multi-thread coordination with a > restore client to ensure each thread can successfully complete each > task it has before accepting more work.  I realize that's actually > difficult to implement. > > There is a plan for a non-text mode for pg_dumpall. I have started work on it, and hope to have a WIP patch in a month or so. It's not my intention to parallelize it for the first cut, but it could definitely be parallelizable in future. However, it will require writing to disk somewhere, albeit that the data will be compressed. It's well nigh impossible to parallelize text format dumps. Restoration of custom and directory format dumps has long been parallelized. Parallel dumps require directory format, and so will non-text pg_dumpall. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com