cockroachdb / cockroachdb/cockroach
sql: investigate errors when preparing DECLARE CURSOR statement in session migration
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
We have noticed that `DECLARE ... CURSOR` statements cannot be prepared correctly when doing a session migration.
```
could not prepare statement during session migration (DECLARE ?"run_log_entries-baad10d2-ac99-4bf5-a0d4-425421a343f6"? CURSOR FOR WITH ?merged_id_entries? AS (SELECT ?run_id?, COALESCE(?untrusted_sequence_id?, ?run_log_entry_id?) AS ?merged_id?, ?event? FROM ?run_log_entry? WHERE (?run_id? = ANY ($1)) AND (?event_type? = ANY ($2:::STRING[]))) SELECT ?r?.?run_id?, ?re?.?merged_id?, ?re?.?event? FROM ?run? AS ?r? LEFT JOIN ?merged_id_entries? AS ?re? ON ((?r?.?run_id? = ?re?.?run_id?) AND (?re?.?merged_id? IS NULL)) OR (((($3:::UUID IS NULL) OR (?re?.?merged_id? > $3:::UUID)) AND (($4::UUID[] = ARRAY[]::UUID[]) OR (?re?.?merged_id? != ALL $4:::UUID[]))) AND (($5:::UUID IS NULL) OR (?re?.?merged_id? < $5:::UUID))) WHERE ?r?.?run_id? = ANY ($1) ORDER BY ?r?.?run_id? ASC, CASE WHEN $6 = ?'first'? THEN ?re?.?merged_id? END ASC, CASE WHEN $6 = ?'last'? THEN ?re?.?merged_id? END DESC LIMIT CASE WHEN $7:::INT8 IS NULL THEN ?NULL? ELSE $7:::INT8 END): no value provided for placeholder: $1
```
https://us5.datadoghq.com/logs?query=source%3Acockroachdb%20env%3Aproduction%20%40cluster_type%3AHOST%20%22could%20not%20prepare%20statement%20during%20session%20migration%22%20-%22does%20not%20exist%22%20%28%22IMPORT%22%20OR%20%22DECLARE%22%29&agg_m=count&agg_m_source=base&agg_t=count&cols=host%2Cservice&fromUser=true&messageDisplay=expanded-lg&refresh_mode=sliding&storage=flex_tier&stream_sort=time%2Cdesc&viz=stream&from_ts=1740672763229&to_ts=1741968763229&live=true
We should investigate why, and determine if these can be prepared successfully.
Jira issue: CRDB-45099
Epic CRDB-60943
Contributor guide
Assessment
This issue has not been assessed yet.