Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timescaledb_toolkit: init at 1.14.0 #186276

Merged
merged 4 commits into from
Mar 11, 2023

Conversation

typetetris
Copy link
Contributor

@typetetris typetetris commented Aug 12, 2022

  1. provide the function buildPgxExtension to build postgresql extensions with cargo-pgx
  2. provide timescaledb_toolkit extension to postgresql build via buildPgxExtension
  3. provide nixos tests making sure resulting timescaledb_toolkit extension can be loaded and used via postgresql nixos module
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Aug 12, 2022
@typetetris
Copy link
Contributor Author

@winterqt @Hoverbear Maybe you want to take a look again.

@typetetris typetetris requested a review from winterqt August 12, 2022 12:13
@typetetris typetetris changed the title Feature/add timescaledb toolkit timescaledb_toolkit: init at 1.8.0 Aug 16, 2022
@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from fd6d7eb to 49144a4 Compare August 16, 2022 17:20
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 labels Aug 16, 2022
@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from 49144a4 to ea2e52e Compare August 29, 2022 07:40
pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix Outdated Show resolved Hide resolved
pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix Outdated Show resolved Hide resolved
pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix Outdated Show resolved Hide resolved
pkgs/development/tools/rust/cargo-pgx/default.nix Outdated Show resolved Hide resolved
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 30, 2022
@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from 4f9fe6c to 472689e Compare October 30, 2022 12:04
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 30, 2022
@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from 0d3c219 to 8c42ec4 Compare October 30, 2022 14:33
@SuperSandro2000
Copy link
Member

@marsam can you please take a look at this?

Also please squash the review commits to follow the contributing guide.

@typetetris
Copy link
Contributor Author

Cross compilation still fails:

at 19:30:46 ❯ nix-build . --arg crossSystem '{config="armv7l-unknown-linux-gnueabihf"; }' -A postgresqlPackages.timescaledb_toolkit
this derivation will be built:
  /nix/store/4g9k3gd471m8159z2r598h61zpmlampn-timescaledb_toolkit-armv7l-unknown-linux-gnueabihf-1.11.0.drv
building '/nix/store/4g9k3gd471m8159z2r598h61zpmlampn-timescaledb_toolkit-armv7l-unknown-linux-gnueabihf-1.11.0.drv'...
unpacking sources
unpacking source archive /nix/store/n2dy6l5in80y08124w638fwqzznbrrwg-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/yfqjw70f43d50q6s5cshahwksc3zl75n-timescaledb_toolkit-1.11.0-vendor.tar.gz
Finished cargoSetupPostUnpackHook
patching sources
Executing cargoSetupPostPatchHook
Validating consistency between /build/source/Cargo.lock and /build/timescaledb_toolkit-1.11.0-vendor.tar.gz/Cargo.lock
Finished cargoSetupPostPatchHook
updateAutotoolsGnuConfigScriptsPhase
configuring
building
Executing cargo-pgx buildPhase
/nix/store/l43k9kqpwdr2a85d278www19k4s6609g-stdenv-linux/setup: line 1403: /nix/store/cdkf0n2g9zf7vknbjp4j4di503dkq3y4-cargo-pgx-armv7l-unknown-linux-gnueabihf-0.4.5/bin/cargo-pgx: cannot execute binary file: Exec format error
error: builder for '/nix/store/4g9k3gd471m8159z2r598h61zpmlampn-timescaledb_toolkit-armv7l-unknown-linux-gnueabihf-1.11.0.drv' failed with exit code 126;
       last 10 log lines:
       > Finished cargoSetupPostUnpackHook
       > patching sources
       > Executing cargoSetupPostPatchHook
       > Validating consistency between /build/source/Cargo.lock and /build/timescaledb_toolkit-1.11.0-vendor.tar.gz/Cargo.lock
       > Finished cargoSetupPostPatchHook
       > updateAutotoolsGnuConfigScriptsPhase
       > configuring
       > building
       > Executing cargo-pgx buildPhase
       > /nix/store/l43k9kqpwdr2a85d278www19k4s6609g-stdenv-linux/setup: line 1403: /nix/store/cdkf0n2g9zf7vknbjp4j4di503dkq3y4-cargo-pgx-armv7l-unknown-linux-gnueabihf-0.4.5/bin/cargo-pgx: cannot execute binary file: Exec format error
       For full logs, run 'nix log /nix/store/4g9k3gd471m8159z2r598h61zpmlampn-timescaledb_toolkit-armv7l-unknown-linux-gnueabihf-1.11.0.drv'.

it somehow uses cargo-pgx compiled for the host platform, despite it being listed in nativeBuildInputs and should be used in the version compiled for the build platform, or not? I have to admit, I don't understand that very well.

@typetetris typetetris changed the title timescaledb_toolkit: init at 1.8.0 timescaledb_toolkit: init at 1.11.0 Oct 30, 2022
@typetetris
Copy link
Contributor Author

Here are some evil hacks with which cargo-pgx/postgresql run at build time, but it now fails at a different place:

Code: typetetris@fa14c5e

Failure:

   Compiling pgx-utils v0.4.5                                                                                                                                 
   Compiling nalgebra v0.27.1                                                                                                                                 
   Compiling pgx-pg-sys v0.4.5                                                                                                                                
   Compiling pgx-macros v0.4.5                                                                                                                                
error: failed to run custom build command for `pgx-pg-sys v0.4.5`                                                                                             
                                                                                                                                                              
Caused by:                                                                                                                                                    
  process didn't exit successfully: `/build/source/target/release/build/pgx-pg-sys-525c36ceb182b0cd/build-script-build` (exit status: 101)                    
  --- stdout                                                                                                                                                  
  cargo:rerun-if-env-changed=PGX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE                                                                                         
  cargo:rerun-if-changed=/build/tmp.HYSAByhqtc/config.toml                                                                                                    
  cargo:rerun-if-changed=include/pg10.h                                                                                                                       
  cargo:rerun-if-changed=include/pg11.h                                        
  cargo:rerun-if-changed=include/pg12.h                                                                                                                       
  cargo:rerun-if-changed=include/pg13.h                                                                                                                       
  cargo:rerun-if-changed=include/pg14.h                                                                                                                       
  cargo:rerun-if-changed=cshim/pgx-cshim.c                                                                                                                    
  cargo:rerun-if-changed=cshim/Makefile                                                                                                                       
                                                                                                                                                              
  --- stderr                                                                                                                                                  
  manifest_dir=/build/timescaledb_toolkit-1.11.0-vendor.tar.gz/pgx-pg-sys                                                                                     
  shim_src=/build/timescaledb_toolkit-1.11.0-vendor.tar.gz/pgx-pg-sys/cshim                                                                                   
  shim_dst=/build/source/target/release/build/pgx-pg-sys-2320b93506f5120f/out/cshim                                                                           
  Generating bindings for pg14                                                                                                                                
  /nix/store/p6knl0hcfah9myg5xzn5kxd1kjp3fiy5-glibc-armv7l-unknown-linux-gnueabihf-2.35-163-dev/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-soft.h' file not found                                                                                                                                                    
  /nix/store/p6knl0hcfah9myg5xzn5kxd1kjp3fiy5-glibc-armv7l-unknown-linux-gnueabihf-2.35-163-dev/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-soft.h' file not found, err: true                                                                                                                                         
  thread 'main' panicked at 'Unable to generate bindings for pg14: ()', /build/timescaledb_toolkit-1.11.0-vendor.tar.gz/pgx-pg-sys/build.rs:530:13            
  stack backtrace:                                                                                                                                            
     0:     0x555555e3898c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf2ea00d5f3b53d9f                             
     1:     0x555555e6a3de - core::fmt::write::ha076a7e65c6b1874                                                                                              
     2:     0x555555e4a671 - std::io::Write::write_fmt::h9630bb3b0fe886f5                                                                                                                                                                                                                                                   
     3:     0x555555e52a45 - std::panicking::default_hook::{{closure}}::h64163197f96398c1                                                                     
     4:     0x555555e526a2 - std::panicking::default_hook::h92625161492e6b48       

Again I am at a loss.

@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from c28d7b6 to b2dc46f Compare October 30, 2022 19:37
@typetetris
Copy link
Contributor Author

Also please squash the review commits to follow the contributing guide.

Partially done. Kept two different commits for cargo-pgx changes and adding timescaledb_toolkit. I would have done two pull requests, but the second one would bring the first tests for the first one, which seems awkward.

@SuperSandro2000
Copy link
Member

Doing this in one PR is fine. The nixos test should also get its own commit.

I think the changes look good from someone that has never worked with postgres plugins.

@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from b2dc46f to c48e061 Compare October 31, 2022 08:28
@typetetris
Copy link
Contributor Author

The nixos test should also get its own commit.

Done.

I also fixed the comment on buildPgxExtension which claimed postgresql was the only argument in addition to all the arguments for buildRustPackage.

@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from c48e061 to 79bb303 Compare November 22, 2022 11:37
@typetetris typetetris changed the title timescaledb_toolkit: init at 1.11.0 timescaledb_toolkit: init at 1.12.1 Nov 22, 2022
@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from 79bb303 to 51f9d74 Compare January 7, 2023 10:19
@typetetris typetetris changed the title timescaledb_toolkit: init at 1.12.1 timescaledb_toolkit: init at 1.13.1 Jan 7, 2023
@typetetris
Copy link
Contributor Author

@SuperSandro2000
@marsam

Updated to 1.13.1 so cargo-pgx 0.5.4 isn't needed any more.

This is open now for quite some time.
What do I need to change, so it can be merge?
Can it be merged at all?

@typetetris typetetris mentioned this pull request Jan 7, 2023
14 tasks
@marsam
Copy link
Contributor

marsam commented Jan 12, 2023

Thanks a lot for working on this and sorry for the delay.

Unfortunately, I've been awful busy with life and work. I'm hoping to review this PR the next week.

@anpin
Copy link
Contributor

anpin commented Jan 21, 2023

thank you @typetetris for your effort! I was able to wrap promscale extension with the help of your buildPgxExtension and would open PR once this one is merged

@SuperSandro2000 SuperSandro2000 added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 21, 2023
@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from 51f9d74 to 05852b2 Compare January 22, 2023 08:13
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 22, 2023
@typetetris typetetris mentioned this pull request Jan 24, 2023
13 tasks
@anpin
Copy link
Contributor

anpin commented Feb 3, 2023

hi everyone, wondering if there are any blockers here preventing the merge? Thanks.

@typetetris
Copy link
Contributor Author

Rebased on master.

@typetetris typetetris force-pushed the feature/add-timescaledb-toolkit branch from 0da6d8b to 9dc7a05 Compare February 13, 2023 09:58
@typetetris typetetris changed the title timescaledb_toolkit: init at 1.13.1 timescaledb_toolkit: init at 1.14.0 Feb 13, 2023
Copy link
Contributor

@marsam marsam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. LGTM overall, thanks a lot for working on this!

export USER="$(whoami)"
pg_ctl start
createuser -h localhost --superuser --createdb "$USER" || true
pg_ctl stop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the pg_ctl stop to the postCheck phase? I'm thinking of starting the server in preBuild and shutting it down in postCheck.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server is only started for the createuser command. Afterwards it is not started again by the build script. I would have to check, whether it is started by cargo pgx.

nixos/tests/all-tests.nix Show resolved Hide resolved

nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
cargo-pgx
postgresql
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think postgresql should be in buildInputs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

Copy link
Contributor Author

@typetetris typetetris Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Maybe timescaledb-toolkit isn't easily cross compiled. cargo pgx wants to call pg_config so we need the postgresql derivation having the timescaledb-toolkits build platform as host platform.

But on the other hand, it builds a library, which hopefully isn't linked against anything from that postgresql package, but just uses the header files from that package and declares some symbols to be resolved at runtime, so it should work against postgresql compiled for a different platform, if cross compiled.

So timescaledb-toolkit shouldn't use anything from that postgresql derivation at runtime.

That is just my understanding.

I will test that, if I can. (Don't you need to by a mac to do darwin builds?)

Typos, Whitespace and Stuff. Will fixup the relevants commits later, so this commit vanishes.

Co-authored-by: Mario Rodas <marsam@users.noreply.github.com>
Copy link
Contributor

@marsam marsam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank a lot for working on this!
If there is no other reviews, I'll merge it this weekend.

@marsam marsam merged commit dae678a into NixOS:master Mar 11, 2023
@anpin anpin mentioned this pull request Mar 12, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants