-
Notifications
You must be signed in to change notification settings - Fork 81
MySQL session store #499
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
MySQL session store #499
Conversation
|
Looking into the build errors. |
|
@LukeMathWalker from what I gathered it's safe to ignore RUSTSEC-2023-0071, while there's no patch available. This fixes https://github.com/LukeMathWalker/pavex/actions/runs/16118570900/job/45478226401?pr=499. I've gone ahead and submitted the update to deny.toml, let me know if you think otherwise? I'm looking into the workspace hack issue |
|
Conflicts resolved and build fixed. |
I don't particularly love it because it doesn't allow us to distinguish between silencing the advisory for that specific link in our dependency tree and silencing the advisory for any usage of the |
Agree, I don't love it at all. But don't see an alternative |
# Conflicts: # libs/Cargo.lock # libs/pavex_session_sqlx/Cargo.toml # libs/px_workspace_hack/Cargo.toml
This reverts commit 644e96b.
|
After merging main, fixing conflicts and running hakari, I see a bunch of packages' Cargo.toml updated with And the top level libs/Cargo.toml has several I'm wondering if the conflict resolution regressed the workspace hack somehow. Gonna investigate and update here. |
I had to merge #512 to re-enable the hack after the release. That should solve the issue. |
# Conflicts: # libs/Cargo.lock # libs/pavex_bp_schema/Cargo.toml # libs/pavex_tracing/Cargo.toml # libs/px_workspace_hack/Cargo.toml
|
👍 I see, merged! |
| // Verify the original data is still there (not overwritten) | ||
| let loaded_after = store.load(&session_id).await.unwrap().unwrap(); | ||
| for (key, expected_value) in &state { | ||
| assert_eq!( | ||
| loaded_after.state.get(key).unwrap(), | ||
| expected_value, | ||
| "Original data should be preserved when session exists" | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not the property we want. It just happens to work because you have created the conflicted state starting from the existing one.
Let's modify the test case to remove this overlap and check that we don't have anything else in the new state beyond the newly created session state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arg, well caught. Will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added some comments to the implementation for clarity on the decision to keep simple upserts.
|
Build is failing due to RUSTSEC-2025-0047, which has been fixed in slab v0.4.11. Looks like it's a dependency of Tokio, but there's no new release for it with the new slab. I tried adding it explicitly to the top level Cargo.toml, but Cargo.lock doesn't seem to update after building. I suspect I may be missing something about Rust dependency management here... |
|
Solved the issue and made a few final tweaks in #532. Merged! |
Closes #464
Demo on https://github.com/oliverbarnes/pavex_mysql_sessions_demo
Follows the Postgres and SQLite session store implementations.
Key differences below, Claude generated (let me know if it's a bit much with the emojis and all):
🗄️ Database Schema Differences
MySQL
PostgreSQL
⏰ Time Handling Differences
MySQL
BIGINT) for deadline storageUNIX_TIMESTAMP()function for current time comparisonsWHERE deadline > UNIX_TIMESTAMP()PostgreSQL
TIMESTAMPTZ)(now() AT TIME ZONE 'UTC')for current time comparisonsWHERE deadline > (now() AT TIME ZONE 'UTC')🔧 SQL Parameter Binding
MySQL
?placeholdersINSERT INTO sessions (id, deadline, state) VALUES (?, ?, ?)PostgreSQL
$1, $2, $3placeholdersINSERT INTO sessions (id, deadline, state) VALUES ($1, $2, $3)🚨 Error Code Handling
MySQL
PostgreSQL
📦 Framework Integration
MySQL
MySqlSessionStorePostgreSQL
PostgresSessionStoreandPostgresSessionKitPostgresSessionKit::new().register(&mut bp)🗂️ JSON Storage
MySQL
JSONcolumn type (MySQL 5.7.8+)PostgreSQL
JSONBcolumn type (binary JSON)🛠️ Migration Complexity
MySQL
CREATE TABLE IF NOT EXISTSstatementPostgreSQL
pg_indexessystem table to avoid duplicate indexes📋 Version Requirements
MySQL
PostgreSQL