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

Upgrade to pgx 0.5.0 #547

Merged
merged 21 commits into from
Oct 17, 2022
Merged

Upgrade to pgx 0.5.0 #547

merged 21 commits into from
Oct 17, 2022

Conversation

syvb
Copy link
Member

@syvb syvb commented Sep 28, 2022

Upgrades to pgx 0.5.0-beta.1 (0.5.0 will hopefully be released in 0-7 days). I originally tested on another branch with a lot of code commented out; this branch cherry picks the commits that fix errors but not the ones that comment code out.

To do:

Future work:

@syvb syvb requested review from JLockerman and removed request for JLockerman September 28, 2022 16:15
@syvb syvb changed the title WIP: pgx 0.5 Upgrade to pgx 0.5 Sep 29, 2022
@@ -4,6 +4,10 @@
#![allow(clippy::extra_unused_lifetimes)]
// every function calling in_aggregate_context should be unsafe
#![allow(clippy::not_unsafe_ptr_arg_deref)]
// since 0.5 pgx requires non-elided lifetimes on extern functions: https://github.com/tcdi/pgx/issues/721
#![allow(clippy::needless_lifetimes)]
Copy link
Member Author

@syvb syvb Sep 29, 2022

Choose a reason for hiding this comment

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

pgx 0.5.0 now requires there to be explicit lifetimes in some cases, despite Clippy claiming they can be removed. I added explicit lifetimes to all of the (many) functions that require them now.

@syvb
Copy link
Member Author

syvb commented Sep 29, 2022

Current status:

  • All tests pass except for these three in datum_utils
    • All three tests error with type with OID 0 does not exist
    • I'm not very familiar with DatumStore so I'm not sure what the issue is there
  • The CI fails since the Docker image hasn't been updated to have a newer cargo-pgx yet
  • update-tester doesn't work with pgx 0.5; hopefully we can move to binary-based testing before merging this to avoid the need to add support a third pgx version to the update tester

@syvb syvb changed the title Upgrade to pgx 0.5 Upgrade to pgx 0.5.0 Sep 29, 2022
bors bot added a commit that referenced this pull request Oct 6, 2022
559: Basic test for space saving aggregate serialization r=Smittyvb a=Smittyvb

I noticed while working on #547 that we don't have any tests for `SpaceSavingAggregate`s. This PR adds a simple test to verify that the `raw_freq_agg` function will at least run without failing.

This test currently fails on #547, which is good since that PR causes a bug that leads to `SpaceSavingAggregate` not working at all.

Co-authored-by: Smitty <smitty@timescale.com>
@syvb syvb force-pushed the sv/pgx-0.5 branch 2 times, most recently from eb6c2e9 to f81179a Compare October 7, 2022 19:20
@epgts epgts requested a review from JLockerman October 7, 2022 23:10
@epgts
Copy link
Contributor

epgts commented Oct 7, 2022

@JLockerman can we get your eyes on this next week?

Thanks!

@syvb syvb marked this pull request as ready for review October 11, 2022 13:08
@syvb
Copy link
Member Author

syvb commented Oct 11, 2022

The CI now passes when I manually run it using the testing Docker image from #571: https://github.com/timescale/timescaledb-toolkit/actions/runs/3230387310/jobs/5288778595

Comment on lines 381 to 392
TableIterator::new(agg.durations.clone().into_iter().map(move |record| {
let beg = record.state_beg as usize;
let end = record.state_end as usize;
(states[beg..end].to_owned(), record.duration)
}))
TableIterator::new(
agg.durations
.clone()
.into_iter()
.map(move |record| {
let beg = record.state_beg as usize;
let end = record.state_end as usize;
(states[beg..end].to_owned(), record.duration)
})
.collect::<Vec<_>>()
.into_iter(),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

pgx requires that a TableIterator/SetOfIterator only see values allocated from Rust (otherwise you get use-after-frees). To comply with this requirement I collect the iterator into a Vec then turn it back into an iterator.

Copy link
Contributor

@WireBaron WireBaron left a comment

Choose a reason for hiding this comment

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

Really nice work.

@jerryxwu jerryxwu mentioned this pull request Oct 14, 2022
3 tasks
@syvb
Copy link
Member Author

syvb commented Oct 14, 2022

Note that pgx 0.5.1 0.5.2 will be released soon. All 0.5.1 0.5.2 does it fix a bug with pg_sys::Point. We don't use Point anywhere so we don't need to update to 0.5.1 0.5.2. We can wait until whatever release adds pg15 support (probably 0.5.2 0.5.3) to update pgx again.

bors bot added a commit that referenced this pull request Oct 17, 2022
571: Update Docker image for pgx 0.5.0 r=Smittyvb a=Smittyvb

pgx 0.5.0 just released! This PR updates the CI to have pgx 0.5.0 and adds pgx 0.5.0 to the `$PATH` instead of pgx 0.4.5.

This PR should be merged right before merging #547 so that the CI can pass on that PR before merging it.

Co-authored-by: Smitty <smitty@timescale.com>
@syvb
Copy link
Member Author

syvb commented Oct 17, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 17, 2022

@bors bors bot merged commit fa7b32f into main Oct 17, 2022
@bors bors bot deleted the sv/pgx-0.5 branch October 17, 2022 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants