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 1tl8mp-009c7w-2S for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 15:48:27 +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 1tl8mm-008bof-KX for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 15:48:24 +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 1tl8mm-008boW-BJ for pgsql-hackers@lists.postgresql.org; Thu, 20 Feb 2025 15:48:24 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tl8mk-001vF1-2T for pgsql-hackers@lists.postgresql.org; Thu, 20 Feb 2025 15:48:23 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-6f7440444efso8173317b3.2 for ; Thu, 20 Feb 2025 07:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740066502; x=1740671302; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dQVZBgnS0QTMDZw3ELyvMGWr7SkavIPd3hSpzKmN33g=; b=nbGkg9SAH2cDk65802RTbQCp0c1ZPqVNrUpfFmVBcpBd1G8afCx+vxYbLt9YpO1+ry Jmaf/qXj6aKNrIO5uVDcsLM8Tx4bXYQz/Y20KQOOp2lTd8f66RwSA9dEaNdqjEY61dLV 7GD3oWAaJcM8W9IhjgT69qvIrQ11+VN+AoY8XqN3hMA39TRJrre6X3cvCVaDyb799iP+ xWeaHF2fnSYaSHKHD/Tmav3TDFtsHoY7QhvzaY+KlUG06Ua1tFD1NIYhNGNU2xEaiFWp tst62nPUPrQnnWyIRwXnR2p+5elu9oAu1w87GcC/1VeT7r7SJl9B5j9ZA6zMqXcxDj5T mORg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740066502; x=1740671302; h=cc: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=dQVZBgnS0QTMDZw3ELyvMGWr7SkavIPd3hSpzKmN33g=; b=D8c/VuqEkc4pXuj1/7xF0IivbA9vJ2t9ie6l84pTRy/CSUTc0JVHnHZoUh5zOCafCx F+6DeP+nvk+t/vuTdeAirLqp22d+NXyAs5PaaKTuhl87LuNM3TtNzKJ8gvmX3k3HcPJ9 NOIhAvfOd5FEonAV8WLWzdsz/twdee4i2Tm0QBp8XKoLTF/wIMNoBg9gm60CduhXsN4x SxxRlnei7mPwlM7rn35IflEgEeirBc1g4g0bWN2xWSF25v+uw1SeR7cWajI+m0NkEmQ2 iETA8ndilTFdInU04kgfmZXISFaXnREYNUQVvq3NY45kvJDxeqfkM8zlC43xnD/YeVPG DOYA== X-Forwarded-Encrypted: i=1; AJvYcCWd9hlyWGIEwb69rS6UIzEgZ5oZGZQRItpd6S2dNXTHQvu5yD8V1qSe/Hj756bqH3yU+wdW72/cfCq8vdKA@lists.postgresql.org X-Gm-Message-State: AOJu0Yxn4N/kPBb6W9rc8FAP0l6GQJzIyntU1SSDwNgIBrrGbCw89HHs APKq2AG5Z0OaXVh7q+wqquqSOJ2uq/RIqa3778kkDEg+UEi3A5pUR0ROkrPlxU8asPea5pe+wMH HCJglaXjh4YQ3segfN5tOHxOvG8Q= X-Gm-Gg: ASbGncvlj2tqqaO9Kw/3vxp8yLTzwRo5SVzaHa1rzuNaIs7Hd2QFu7B/z5FGLNm8aFm 61Q/sYTxyRxt7xFAlRkCs7dQvGsIJ6SCf7qWYBZRe210O79JUpbj0yCw7pwrGqoqXEclGPEo= X-Google-Smtp-Source: AGHT+IGl62SZ4OCI3vKnM1ZFTko6m3jXBymaHF+VUS00cg8mAP+dxvjxWoTrJR2cEDWKkpJq4PPmV19f8fdRLFH9cOA= X-Received: by 2002:a05:690c:6287:b0:6f9:7d7d:a725 with SMTP id 00721157ae682-6fb58390b21mr192338717b3.33.1740066501670; Thu, 20 Feb 2025 07:48:21 -0800 (PST) MIME-Version: 1.0 References: <202502050844.4lrgg3aoudat@alvherre.pgsql> In-Reply-To: From: vignesh C Date: Thu, 20 Feb 2025 21:18:10 +0530 X-Gm-Features: AWEUYZknwdeNm0KOhCtgHQ5UiOglgWT71X_0QLd79XdGBUeQqixogoHsBsuy3tI Message-ID: Subject: Re: Restrict publishing of partitioned table with a foreign table as partition To: Shlok Kyal Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Sergey Tatarintsev , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 18 Feb 2025 at 15:59, Shlok Kyal wrote: > > On Mon, 17 Feb 2025 at 20:13, vignesh C wrote: > > > > On Fri, 14 Feb 2025 at 12:59, Shlok Kyal wrote: > > > > > > I have used the changes suggested by you. Also I have updated the > > > comments and the function name. > > > > There is another concurrency issue possible: > > +/* Check if a partitioned table has a foreign partition */ > > +bool > > +check_partrel_has_foreign_table(Form_pg_class relform) > > +{ > > + bool has_foreign_tbl = false; > > + > > + if (relform->relkind == RELKIND_PARTITIONED_TABLE) > > + { > > + List *relids = NIL; > > + > > + relids = find_all_inheritors(relform->oid, NoLock, NULL); > > > > Create a publication with publish_via_partition_root as true, hold the > > execution after check_partrel_has_foreign_table execution finishes. > > Then parallely execute the following: > > CREATE TABLE t1(id int) PARTITION BY RANGE(id); > > CREATE TABLE part1 PARTITION OF t1 FOR VALUES FROM (0) TO (5); > > CREATE TABLE part2 PARTITION OF t1 FOR VALUES FROM (5) TO (15) > > PARTITION BY RANGE(id); > > CREATE FOREIGN TABLE part2_1 PARTITION OF part2 FOR VALUES FROM (10) > > TO (15) SERVER fdw > > > > Now both the partitioned table having foreign table and a publication > > will be created. > > > > Hi Vignesh, > > I have addressed the above issue. If we take a ShareLock on the > pg_class, we won't be able to create table concurrently, which may > address the issue. Thoughts? > I have attached the v8 patch here. Since pg_class is a very common table it is not a good idea to take ShareLock on it. Will it be possible to use pg_partitioned_table table instead? Regards, Vignesh