sql: migrate prepared statements during session migration#76399
sql: migrate prepared statements during session migration#76399craig[bot] merged 5 commits intocockroachdb:masterfrom
Conversation
otan
left a comment
There was a problem hiding this comment.
changes lgtm.
one thing i am curious about - what happens to prepared statements if a schema change happened and the types change? in turn, does AddPreparedStatement during a session migration potentially change the result of the prepared statement producing an entirely different statement? is it worth testing?
|
CC @RaduBerinde to make sure to take a look at this. |
This is the behavior without any session migration involved:
yeah we definitely should test. given the above, i guess the two options are to not serialize a prepared statement if it's not valid at the time of serialization, or to ignore certain types of prepare errors at the time of deserialization. |
|
We could also keep the behavior as-is and just error out. (The user-impact is that their client would get a hard disconnect rather than a graceful session migration.) |
|
happy with erroring out. also happy for you to add this test in a separate PR. |
347fce3 to
a1477d2
Compare
|
confirmed the behavior for prepared statements after a schema change at the last multi-tenant team meeting with signoff from @jeffswenson so going to merge this. bors r=otan |
a1477d2 to
ad02cf5
Compare
|
Canceled. |
|
bors r=otan |
jaylim-crl
left a comment
There was a problem hiding this comment.
I believe this will fail:
cockroach/pkg/ccl/testccl/sqlccl/show_transfer_state_test.go
Lines 199 to 225 in 696cdd5
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @jaylim-crl and @rafiss)
pkg/sql/types/types.go, line 1746 at r5 (raw file):
// messages
//and also to produce the output of SHOW CREATE.
nit: typo here?
|
Build failed (retrying...): |
rafiss
left a comment
There was a problem hiding this comment.
ah, whoops. fixing
bors r-
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @jaylim-crl)
pkg/sql/types/types.go, line 1746 at r5 (raw file):
Previously, jaylim-crl (Jay Lim) wrote…
// messages
//and also to produce the output of SHOW CREATE.nit: typo here?
fixed
|
Canceled. |
ad02cf5 to
762f214
Compare
rafiss
left a comment
There was a problem hiding this comment.
@jaylim-crl i edited that test, in case you want to take a look
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @jaylim-crl)
|
edit: nvm i see it is done above |
jaylim-crl
left a comment
There was a problem hiding this comment.
@jaylim-crl i edited that test, in case you want to take a look
Thanks. The test LGTM.
Reviewed 2 of 2 files at r1, 2 of 2 files at r2, 4 of 4 files at r3, 13 of 16 files at r4, 4 of 4 files at r6, 3 of 3 files at r7, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
This will allow us to more easily call into the code to prepare statements when deserializing. Release note: None
Release note: None
After the recent refactor for deserialize_session, it no longer needs to be exposed. Release note: None
Release note (sql change): The crdb_internal.serialize_session and crdb_internal.deserialize_session now can handle prepared statements. When deserializing, any prepared statements that existed when the session was serialized are re-prepared. It is an error to re-prepare a statement if the current session already has a statement with that name.
A schema change can make an existing prepared statement invalid. Rather than returning an error when deserializing that invalid statement, now the error will be returned only when trying to use the statement. This makes a session migration even more transparent to the end user. Release note: None
762f214 to
dda2fa9
Compare
|
tftrs! bors r=otan |
|
Build failed (retrying...): |
|
Build failed: |
|
the failures all seem to be flakes as far as i can tell.. bors r=otan |
|
Build failed: |
|
yet another flake.. bors r=otan |
|
Build succeeded: |
|
congrats on winning the CI lottery! |
fixes #76398
See individual commits. The last one contains the business logic changes,
and the rest are just refactors.
Release note (sql change): The crdb_internal.serialize_session and
crdb_internal.deserialize_session now can handle prepared statements.
When deserializing, any prepared statements that existed when the
session was serialized are re-prepared. It is an error to re-prepare a
statement if the current session already has a statement with that name.