Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1papyN-0006kM-HF for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Mar 2023 03:32:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1papyL-00086X-J9 for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Mar 2023 03:32:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1papyL-00086O-9k for pgsql-hackers@lists.postgresql.org; Sat, 11 Mar 2023 03:32:41 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1papyI-0000ZH-Um for pgsql-hackers@lists.postgresql.org; Sat, 11 Mar 2023 03:32:40 +0000 Received: by mail-pj1-x102f.google.com with SMTP id me6-20020a17090b17c600b0023816b0c7ceso11837575pjb.2 for ; Fri, 10 Mar 2023 19:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678505558; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mD4MkRbHJ4mWeq8L05YIv1O/BE1tGwXySJydqjAVG2M=; b=nENEgqt8YLtf/TQ1DDlDn7p1Wv3TY3yVoRsERQ3XBp0cWaUcjvo4nO1GytSnqnsuVC 6Qxipm0XLBTLUbG2WHghujtq1I2PUs/qBlfpKY50c6d4Zy5YNHHYs+OoucOLnvcw6WyH j+VJrjS1qmmqyCDMPgdW/MXB/nTtnxXdaeCcPW0NXDqDRbFYUZBbh0kwGYujzWCBBLwS RwUMrZxZlqVEh6Pu2JM5GKwOfR2Zp7HIBdIjtfNKEjHfOdCRRI0AUJ0jxVQSfetyivdn fLQZWnuI5BWTM58QMU3vUiBE89JfV0HJB/rE5wKu/7XwG7WZ1HZt4fUf19rGpFYNJnyT xXvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678505558; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mD4MkRbHJ4mWeq8L05YIv1O/BE1tGwXySJydqjAVG2M=; b=jYYpJmiCwA160+Zsruf9DxoCKqv6jlQNPWI0S5XQJ1FUQDIfcES5Kc9NQvtEm9vjar VFKhLpsKzKQr/G1t8kegooXKGK5nU2OAlzauy+OYzNoxKY7nJ2+N+wKwlaQOhwxIrCaD mMawRhn0pu0gS0vm67uKlj2brnyH281C+rvbVUROqSFZ0SjUlvb8XCikzAreQZr3ub4D Wa/FavAP3xoELeiaCEsnhQ/Nbdinh4X44NPo9u7i+yeLUr421lAXRMICSMlxbE3pm0LY QxzJMQKdKBS0mio2m4XAGUrJHlfA6YPgorDPSovu0Ny1wPKq+AilC5NtcVE69F/6FNWp ak0A== X-Gm-Message-State: AO0yUKWGI23rmJTGYZkAps05Z8E6GImpffpT4SjsFnw5/EaUhRw/cP2N njJ8KT7zrnek3CM5gZXLlhw= X-Google-Smtp-Source: AK7set8W9CjcYaw6h9bw4/9u3JYzqqhXZESRrnNqkSVlcztgHxk5RPXdrSjuvou1fxFf6/FlrRUInw== X-Received: by 2002:a05:6a20:4f24:b0:cd:9da2:fdb8 with SMTP id gi36-20020a056a204f2400b000cd9da2fdb8mr23536911pzb.34.1678505557629; Fri, 10 Mar 2023 19:32:37 -0800 (PST) Received: from jrouhaud (2001-b011-1005-7577-f429-b80e-6535-5d13.dynamic-ip6.hinet.net. [2001:b011:1005:7577:f429:b80e:6535:5d13]) by smtp.gmail.com with ESMTPSA id x26-20020aa7919a000000b005a8cc32b23csm510804pfa.20.2023.03.10.19.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 19:32:36 -0800 (PST) Date: Sat, 11 Mar 2023 11:32:32 +0800 From: Julien Rouhaud To: Tom Lane Cc: Andrew Dunstan , Alvaro Herrera , David Rowley , Peter Geoghegan , Robert Haas , pgsql-hackers@lists.postgresql.org, Andrew Subject: Re: pg_dump versus hash partitioning Message-ID: <20230311033232.g6jgkuzxdawepsbe@jrouhaud> References: <1425446.1675291093@sss.pgh.pa.us> <1440373.1675299790@sss.pgh.pa.us> <1533086.1675349554@sss.pgh.pa.us> <1912821.1676402493@sss.pgh.pa.us> <20230311030154.pg63uspio35h4a6t@jrouhaud> <1078804.1678504214@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1078804.1678504214@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 10, 2023 at 10:10:14PM -0500, Tom Lane wrote: > Julien Rouhaud writes: > > Working on some side project that can cause dump of hash partitions to be > > routed to a different partition, I realized that --load-via-partition-root can > > indeed cause deadlock in such case without FK dependency or anything else. > > > The problem is that each worker will perform a TRUNCATE TABLE ONLY followed by > > a copy of the original partition's data in a transaction, and that obviously > > will lead to deadlock if the original and locked partition and the restored > > partition are different. > > Oh, interesting. I wonder if we can rearrange things to avoid that. The BEGIN + TRUNCATE is only there to avoid generating WAL records just in case the wal_level is minimal. I don't remember if that optimization still exists, but if yes we could avoid doing that if the server's wal_level is replica or higher? That's not perfect but it would help in many cases.