-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inconsistency of
kernels.session_name
column (#1985)
Co-authored-by: Sion Kang <[email protected]> Backported-from: main (24.09) Backported-to: 24.03
- Loading branch information
1 parent
9df6e7d
commit af42d4a
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sync mismatch between `kernels.session_name` and `sessions.name` and fix session-rename API to update `session_name` of sibling kernels atomically. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
.../manager/models/alembic/versions/dddf9be580f5_sync_kernelssessionname_to_real_session_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""sync_kernelssessionname_to_real_session_name | ||
Revision ID: dddf9be580f5 | ||
Revises: 857b763b8618 | ||
Create Date: 2024-04-01 16:58:14.341114 | ||
""" | ||
|
||
import textwrap | ||
|
||
from alembic import op | ||
from sqlalchemy.sql import text | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "dddf9be580f5" | ||
down_revision = "857b763b8618" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
conn = op.get_bind() | ||
sync_stmt = textwrap.dedent( | ||
""" | ||
UPDATE kernels | ||
SET session_name = sessions.name | ||
FROM sessions | ||
WHERE kernels.session_id = sessions.id | ||
AND kernels.session_name <> sessions.name; | ||
""" | ||
) | ||
conn.execute(text(sync_stmt)) | ||
|
||
|
||
def downgrade(): | ||
pass |