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.96) (envelope-from ) id 1vyAND-00HVLm-0f for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 15:12:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyANB-0008KC-1X for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 15:12:21 +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.96) (envelope-from ) id 1vyANB-0008K2-0d for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 15:12:21 +0000 Received: from mail-dl1-x1230.google.com ([2607:f8b0:4864:20::1230]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vyAN9-00000000YGf-1rtE for pgsql-hackers@postgresql.org; Thu, 05 Mar 2026 15:12:20 +0000 Received: by mail-dl1-x1230.google.com with SMTP id a92af1059eb24-1271257ae53so9826305c88.1 for ; Thu, 05 Mar 2026 07:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772723538; x=1773328338; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=lVMkf/H4LIhl7Xa97cc9is/o2FHzXvo/9M0QLOVZNiw=; b=L/weDwG5v/x40I1ewRCOwtYX0mWu5DENjLqI0qt4w2G5jnWO5Qa7hkles0jxHxAjln QnnPIHVITjJTSKgwm8hvUFdEOLJIS5mXpMf4FBardeqsrzJOIZ4lzAb4EXv0EZuy+F1j JB5rq/SVtRUrbYbyPydd+n5dHPHid+BmVjmaAh0vW8vO38XIltDIGZvmwdicQ9ld/r0S tTo9+sNzYNFxcplObAJZyRBJaSCEoja7Y/m1jpHLESZouTKtyC3FO9I/SL23s/dHsFY3 fDauRjfq0UXY+U0jmBpPdsdZCBIs7jFXQQl2p7kmfnMvQyPewdMbQ1zDTyxVrLRqZqbI 6ujw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772723538; x=1773328338; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lVMkf/H4LIhl7Xa97cc9is/o2FHzXvo/9M0QLOVZNiw=; b=eGEz9PqlJcluRc16ZPM4Vo5iFngEym4n2YvwnvarCuSjlI0YWM1jQmzDBNOc6glqbn JfVGKZlgkqu8+/lh/fjbaVI6JNF/MYuvirbumr4WCIHKLDGo6ywWn231Gx1E7QidQox9 TgF4E7ZQPJK1dI6QTYDb2Yz9a2zCaUeIRXG40VV1hpLXIyGjrfY1IPbgyexGn+Hg3Acl ARW7DWgyLGkLn82UchF+m5jHN6KWEqgnH9+fG1wk8fPv9bvGEdS6rvCF6NAgLHyZirnu KVTxf4Szqh80rYzMDNW9ZIjq3nPB/vOr89YZE7L1wgbJmKRx5IzCbnahrRGYZMC/VeS7 VP1A== X-Forwarded-Encrypted: i=1; AJvYcCVQfuRr7dcdgy0BfBcFJCqRPHRWmgGED3eE9GNUie4Y/IWmwSY6XcXtuJV+QEBe2xGv0BayhWyqLHQoIsml@postgresql.org X-Gm-Message-State: AOJu0YwGFnHu48rPa2QCXPz/jfKSkmf1XNSvWQtdVUfOhaijXt3gw+oK zdb3LBEX3OUrXHLv6iHsCVjWleXFqoZZ7uOCY9M7I4PKoZGjMt/GMGKi X-Gm-Gg: ATEYQzytwcfnHCqASMhqiAewod7IzxhSpThpMGc90QpwMbd1+8XpEJCTKHK0X2R4eye RUC4APGiOUkThRCN2tEIFQa+F5tiQuxZ876ApECjLlxp8heUXkzQd4N9wdX0IDS6jl5Remjo/Tt pTsYIsJDZj8qXYLMIYdm3sWybIYVUvlAugQRBf6ef/PwLTs85p3lZbT1IYOK8U1LpomRhIVvQqN zEmE+uLX2kBgUV5ikkWsCgzrxOTQ8hoHCD8kS/F8YfrKO0iRHKyX3JjrQRcMEdtTET9N1mmOgm2 fFla9euXkbcvwB+YMwNalFA/riL+OW5/MoQRuSCj/DEHdRhSAI7En4mXUuxqQFOY5L7k6tQi9Ib PuXR1NkBjKh7Zx6H/yd6+Mt7QyU+/mIeg/wiTZ2ONvpVgNyjiRF3raPLYkn8Xn+dodNBk96UVit ayDtqpqbOq2lWsKknCCzG4F19wgYGWAyBEehXLm6fJ1bgumGtlD3yamhHM03UtqgPX5Ov/5l9cg hPuGGbDQ2EDTsOaw5uq X-Received: by 2002:a05:7022:113:b0:124:9fd8:4b97 with SMTP id a92af1059eb24-128c107e589mr58811c88.8.1772723538223; Thu, 05 Mar 2026 07:12:18 -0800 (PST) Received: from [192.168.4.100] (163.116.230.145.netskope-rdns.com. [163.116.230.145]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12789a32863sm20467567c88.10.2026.03.05.07.12.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Mar 2026 07:12:17 -0800 (PST) Message-ID: <984363e5-5f3f-4018-9f9e-c27406848151@gmail.com> Date: Thu, 5 Mar 2026 12:12:14 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_upgrade fails when extension_control_path is used To: "Jonathan Gonzalez V." , PostgreSQL Hackers References: <43b3691c673a8b9158f5a09f06eacc3c63e2c02d.camel@gmail.com> Content-Language: en-US From: Matheus Alcantara In-Reply-To: <43b3691c673a8b9158f5a09f06eacc3c63e2c02d.camel@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 03/03/26 05:15, Jonathan Gonzalez V. wrote: > The upgrade process from 18 to 19devel using `extension_control_path` > fails due to some extensions having the `$libdir/` string hard coded in > the `module_pathname`. > > The finding was done by Niccolo Fei while working on the images > extension in CloudNativePG, this feature relies on the > `extension_control_path` GUC that was included in PostgreSQL 18 to > allow having extension in small images. This is done by having a > directory layer with two main paths, one for the extension `.sql` and > `.control` files, and another for the `.so` files or any file that > requires to be added into the `dynamic_library_path`. These two things > trigger the bug during the upgrade. > > The problem may look simple and like it can be reproduced with any lib > that is added to the `dynamic_library_path`, What do you mean by this? Manually executing LOAD '$libdir/foo' will fail if the lib "foo" does not exists on $libdir and this is an expected behavior since the user is forcing to load the lib from $libdir path. If user execute LOAD 'foo' it will search on dynamic_library_path along with extension_control_path. See the commit message of f777d773878. > but the problem is due to > `pg_upgrade`. Using the `probin` field from `pg_catalog.pg_proc` as the > string used to pass to the `LOAD` instruction when loading the > extension again during the upgrade process gives the following error: > > could not load library "$libdir/test_ext": ERROR: could not access > file "$libdir/test_ext": No such file or directory > > This problem was already difficult to explain so I decided to create a > test for this, and the error above is the result of the test without > the patch to the `function.c` file. > > The patch uses pretty much the same technique that was used in the > `extenion_control_path` patch, that it removes the `$libdir/` string > when the name of the extension is required. > I was not fully happy with the strip hack on extension_control_path on the time and I have the same felling here but I don't think that we have another way to fix this issue, at lest I couldn't think it. The patch seems correct to me because we don't want to have this on LOAD command itself since the user may want to load an extension from $libdir so the strip logic on pg_upgrade is more appropriate. I'm wondering if we need to handle nested paths on pg_upgrade in the same way that we handle on load_external_function(), I think that is not needed but it can be good to double check. One minor comment is that the code comment on function.c can be similar to what we have on load_external_function(): /* * For extensions with hardcoded '$libdir/' library names, we * strip the prefix to allow the library search path to be used. */ > The implementation of the test is something that I would like to get > help on, I moved the location a couple of times to arrive to this one > because it didn't fit in any other place. Also, it makes it easier to > implement the `make` support for it, but I'm still having doubts if > it's the right place. > I personally don't see any issue on keeping the new TAP test on pg_upgrade/t with the other ones since this issue is related with pg_upgrade itself, but others can have other opinions on this. > I'm attaching the patch with the fix and also with the test for it. > Thanks for reporting this and for sharing the patch. -- Matheus Alcantara EDB: https://www.enterprisedb.com