plrust icon indicating copy to clipboard operation
plrust copied to clipboard

Recent package upgrades are breaking 1.2.7 builds

Open jscheid opened this issue 1 year ago • 5 comments

It seems that a few hours ago, a number of new package versions were released that are picked up by plrust builds but fail because they're incompatible with older rust versions. I could be missing some details here but anyway, this is a temporary workaround in case anybody finds it useful:

diff --color -ru ../plrust-1.2.7/plrust/Cargo.toml ./plrust/Cargo.toml
--- ../plrust-1.2.7/plrust/Cargo.toml	2023-11-18 17:44:58.000000000 +0100
+++ ./plrust/Cargo.toml	2025-02-26 23:28:45.770122468 +0100
@@ -62,6 +62,10 @@
 proc-macro2 = "1"
 omnipath = "0.1.6"
 
+# overrides
+litemap = { version = "=0.7.4", forced = true }
+zerofrom = { version = "=0.1.5", forced = true }
+
 [target.'cfg(target_os="linux")'.dependencies]
 memfd = "0.6.4" # for anonymously writing/loading user function .so
 
diff --color -ru ../plrust-1.2.7/plrust/src/user_crate/crating.rs ./plrust/src/user_crate/crating.rs
--- ../plrust-1.2.7/plrust/src/user_crate/crating.rs	2023-11-18 17:44:58.000000000 +0100
+++ ./plrust/src/user_crate/crating.rs	2025-02-26 23:22:29.514979073 +0100
@@ -250,6 +250,9 @@
 
         [dependencies]
         pgrx = { version = trusted_pgrx_version, package = "plrust-trusted-pgrx" }
+        home = { version = "=0.5.9", forced = true }
+        litemap = { version = "=0.7.4", forced = true }
+        zerofrom = { version = "=0.1.5", forced = true }
 
         /* User deps added here */
 

Is there's any less hacky solution, and is my understanding correct that 1.2.7 requires Rust 1.72.0, which is incompatible with the latest versions of these packages?

Could these and other dependencies be nailed down more inCargo.toml and the template? It would be good to know that some other package being upgraded next week won't cause similar issues.

jscheid avatar Feb 26 '25 23:02 jscheid

@jscheid, thanks for sharing your workaround – I can confirm it works for us as well.

andreas avatar Feb 27 '25 13:02 andreas

We've also encountered this issue, thanks for the workaround!

iliastsa avatar Mar 06 '25 14:03 iliastsa

We encountered a similar error again recently and had to expand the list of pinned dependencies to include idna_adapter locked at version 1.2.0:

diff --color -ru ../plrust-1.2.7/plrust/Cargo.toml ./plrust/Cargo.toml
--- ../plrust-1.2.7/plrust/Cargo.toml   2023-11-18 17:44:58.000000000 +0100
+++ ./plrust/Cargo.toml 2025-02-26 23:28:45.770122468 +0100
@@ -62,6 +62,11 @@
 proc-macro2 = "1"
 omnipath = "0.1.6"

+# overrides
+litemap = { version = "=0.7.4", forced = true }
+zerofrom = { version = "=0.1.5", forced = true }
+idna_adapter = { version = "=1.2.0", forced = true }
+
 [target.'cfg(target_os="linux")'.dependencies]
 memfd = "0.6.4" # for anonymously writing/loading user function .so

diff --color -ru ../plrust-1.2.7/plrust/src/user_crate/crating.rs ./plrust/src/user_crate/crating.rs
--- ../plrust-1.2.7/plrust/src/user_crate/crating.rs    2023-11-18 17:44:58.000000000 +0100
+++ ./plrust/src/user_crate/crating.rs  2025-02-26 23:22:29.514979073 +0100
@@ -250,6 +250,10 @@

         [dependencies]
         pgrx = { version = trusted_pgrx_version, package = "plrust-trusted-pgrx" }
+        home = { version = "=0.5.9", forced = true }
+        litemap = { version = "=0.7.4", forced = true }
+        zerofrom = { version = "=0.1.5", forced = true }
+        idna_adapter = { version = "=1.2.0", forced = true }

         /* User deps added here */

iliastsa avatar Jun 03 '25 14:06 iliastsa

@jscheid, @iliastsa Thank you for sharing your workarounds! I had to go even further with version pinning:

diff --git c/plrust/Cargo.toml i/plrust/Cargo.toml
index 43fb5a0..b454660 100644
--- c/plrust/Cargo.toml
+++ i/plrust/Cargo.toml
@@ -31,7 +31,7 @@ force_enable_x86_64_darwin_generations = []
 cfg-if = "1" # platform conditional helper
 once_cell = "1.18.0" # polyfills a nightly feature
 semver = "1.0.20"
-home = "0.5.5" # where can we find cargo?
+home = "=0.5.5" # where can we find cargo?
 
 # working with our entry in pg_catalog.pg_proc
 base64 = "0.21.5"
@@ -62,6 +62,12 @@ quote = "1"
 proc-macro2 = "1"
 omnipath = "0.1.6"
 
+# overrides
+backtrace = { version = "=0.3.69" }
+idna_adapter = { version = "=1.2.0" }
+litemap = { version = "=0.7.4" }
+zerofrom = { version = "=0.1.5" }
+
 [target.'cfg(target_os="linux")'.dependencies]
 memfd = "0.6.4" # for anonymously writing/loading user function .so
 
diff --git c/plrust/src/user_crate/crating.rs i/plrust/src/user_crate/crating.rs
index d48cc9f..1cdae7e 100644
--- c/plrust/src/user_crate/crating.rs
+++ i/plrust/src/user_crate/crating.rs
@@ -250,6 +250,10 @@ pub(crate) fn cargo_toml_template(crate_name: &str, version_feature: &str) -> to
 
         [dependencies]
         pgrx = { version = trusted_pgrx_version, package = "plrust-trusted-pgrx" }
+        home = { version = "=0.5.9" }
+        litemap = { version = "=0.7.4" }
+        zerofrom = { version = "=0.1.5" }
+        idna_adapter = { version = "=1.2.0" }
 
         /* User deps added here */
 

allenap avatar Jun 04 '25 09:06 allenap

We use a patch against plrust for running Cargo in offline mode, which may help with this issue. The patch considerably improves the time to define plrust functions, which was the original motivation. Without offline mode, we spent ~5 min to define ~35 UDFs with plrust in CI — with offline mode it takes ~5s.

Using offline mode also helps with reproducibility though. When defining a function with plrust, Cargo will find the most recent packages for all transitive dependencies and recompile as necessary. This means a new release of a transitive dependency can cause breakage, as evidenced by this issue. With offline mode, all package versions are pinned down.

I should caveat the patch by saying that I'm not a Rust programmer, the patch is untested, and it's only been used in test environments. That being said, we've used it for a month to great effect. Here's the patch:

https://github.com/andreas/plrust/commit/74a56bfdcdc6ca7d8eeeb47700d79ff1f00efc78

The patch introduces a new GUC, plrust.offline_mode, which adds the --offline flag to Cargo when set to true.

We use the patch as follows:

  1. Set up Postgres and install plrust.
  2. Define a dummy plrust function (plrust.offline_mode should be false, the default). Cargo will download packages at this point. You can drop the function again if you want to keep a clean slate.
  3. Set plrust.offline_mode to true.
  4. All subsequent function definitions using plrust will use the packages installed in step 2, even if new package versions are released.

In our case, steps 1-3 are done in a Docker image that's rarely updated, and step 4 is done separately and much more frequently.

andreas avatar Jun 04 '25 14:06 andreas