-
Notifications
You must be signed in to change notification settings - Fork 628
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
Port to diesel 2.0.3 #4892
Port to diesel 2.0.3 #4892
Conversation
To just leave a comment here: Feel free to reach out to me for anything diesel related. I'm happy to provide any additional information that would be required for this update (or any other feature). That would also allow us to release an updated |
☔ The latest upstream changes (presumably 1efe1d5) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably 3d71217) made this pull request unmergeable. Please resolve the merge conflicts. |
@jtgeibel Is there anything I can help with here? |
Thanks @weiznich. I've finally been able to make some good progress with updating the background job logic to reuse an existing database connection in a85f62c. I'm a little unsure about the Other than that, I think this is finally getting close to moving out of draft. There are just a few remaining test failures that I haven't had a chance to look into yet. And we'll need a better long-term fix for cb19137. (cc @Turbo87 the new token scopes / auth is causing a re-entrant access to the test connection in the publish endpoint. For now I just drop the connection before auth and obtain a new one after.) |
👍 I will have a look at a85f62c next week |
☔ The latest upstream changes (presumably 5ceed51) made this pull request unmergeable. Please resolve the merge conflicts. |
I left a comment on the implications of I'm happy to help with further input resolving this issue. |
I've rebased and squashed this PR on top of latest master. There are 5 failing |
The rollback code is here. The main change there is that we now handle cases where we cannot rollback to safe points and have a much stricter tracking of the transaction depth. In addition we've introduced additional checks to see whether a transaction manager contains open transactions or not. These information is used by the |
I've pushed a commit simplifying the background worker rollback logic and another commit with a few cleanups I found while reviewing the diff. There is just one failing test. It seems there is a subtle difference in how transaction rollback works when the commit fails due to a
This appears to only be an issue with the test, as when I ran in readonly mode locally cargo gave me the following expected error when I attempted to yank a crate:
In production, this code runs outside of any transactions, so the transaction used to attempt the update is a real transaction, however when testing we are already in a transaction, so the update is attempted within a SAVEPOINT. In the test we also create our own SAVEPOINT which diesel isn't aware of.. I did some testing in |
☔ The latest upstream changes (presumably #5903) made this pull request unmergeable. Please resolve the merge conflicts. |
I've opened diesel-rs/diesel#3470 to track the remaining test failure, as I believe this is an unintended change in upstream behavior. |
☔ The latest upstream changes (presumably bac756e) made this pull request unmergeable. Please resolve the merge conflicts. |
With the latest upstream diesel changes in the 2.0.3 release, our final failing test is now passing! Moving out of the draft state. 🎉 |
If the attempt to rollback the transaction fails, with Diesel 2.0 it is now okay to drop the connection as it will be closed instead of being returned to the pool.
With this upstream change, our final failing test now passes!
The schema.patch file is updated to rollback the new `Nullable` in `Array<Nullable<_>>`: * api_tokens.crate_scopes * api_tokens.endpoint_scopes * dependencies.features I've confirmed there there are no existing null values in any of these arrays in the production database.
Last week I made another pass over this PR and realized that at some point I downgraded back to deisel_cli 1 so this was missing changes to the Included in the I've rebased this on master so that I can deploy this on staging for some additional testing. We should be able to merge this in a day or two. |
Merged and deployed! |
Diesel was upgraded to version 2 in rust-lang#4892, but the contributing instructions still have the reader install diesel_cli 1.x, which will result in some fun errors when it attempts to regenerate `src/schema.rs` when running `diesel migration run`, as recommended later in the contributing guide.
Diesel was upgraded to version 2 in #4892, but the contributing instructions still have the reader install diesel_cli 1.x, which will result in some fun errors when it attempts to regenerate `src/schema.rs` when running `diesel migration run`, as recommended later in the contributing guide.
With the latest upstream diesel changes in the 2.0.3 release, our final failing test is now passing!
Original PR Text
This is a nearly complete port to diesel 2, with the following exceptions:
diesel_full_text_search
(an upstream PR) andswirl
(a development branch here).&PgConnection
to&mut PgConnection
, it seems to no longer be possible to run the test suite with a single connection, as required by our background job tests. The current design uses a re-entrant mutex , but this no longer works and unless I'm missing something, there is (for good reason) no safe API to hand out multiple&mut
to the same location even if we're on the same thread. Maybe we can rework theswirl
backend to add support for our test harness.Any suggestions on how to resolve this are greatly appreciated!