Session.GetSessionSysVar returns nil for registered sysvars missing from the per-session map - #24530
Merged
mergify[bot] merged 3 commits intoMay 21, 2026
Merged
Conversation
… map miss
Session.GetSessionSysVar previously returned interface{}(nil) when
ses.sesSysVars.Get(name) saw a map miss for a registered sysvar.
sesSysVars is a clone of the per-account snapshot from
mo_mysql_compatibility_mode; sysvars added to gSysVarsDefs without a
corresponding catalog row are absent from the cloned map, and Get
returns interface{}(nil) on map miss instead of the registered
Default. That violates MySQL `SELECT @@name` semantics (session value
> global default, never nil for a registered name) and breaks
downstream consumers like sub-Compiles spawned by CREATE TABLE CLONE
that try to read vector-index sysvars (ivf_threads_build,
kmeans_train_percent, ...) — they receive nil and either fail or
silently use zero values.
The function already had a wholesale-nil fallback (`if ses.sesSysVars
== nil { return gSysVarsDefs[name].Default }`); this commit extends it
to cover the per-key map-miss case, the realistic scenario for any
sysvar registered after the per-account snapshot was taken.
New TestGetSessionSysVar_MapMissFallsBackToDefault asserts both
`ivf_threads_build` (int64 default 0) and `kmeans_train_percent`
(float64 default 10) resolve correctly when the per-session map is
empty.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
approved these changes
May 21, 2026
XuPeng-SH
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the Session.GetSessionSysVar fallback change and the added regression test. The change is small, localized, consistent with the existing nil-session fallback behavior, and the focused frontend sysvar tests passed locally.
Contributor
Merge Queue Status
This pull request spent 1 hour 3 minutes 53 seconds in the queue, including 1 hour 3 minutes 18 seconds running CI. Required conditions to merge
|
ULookup
pushed a commit
to ULookup/matrixone
that referenced
this pull request
May 26, 2026
…rom the per-session map (matrixorigin#24530) 1. Fix SystemVariables.Get to fall back internally. Broader scope (SystemVariables would need to know about gSysVarsDefs), but covers any direct caller of Get too. 2. Pre-populate sesSysVars at session creation by merging gSysVarsDefs defaults into the cloned account snapshot. Most principled — the per-session map becomes complete — but more invasive at session-init time. Going with the localized fix in GetSessionSysVar as the lowest-risk first step; options 1/2 can follow if the same nil-on-miss pattern bites other call sites. Tests TestGetSessionSysVar_MapMissFallsBackToDefault (pkg/frontend/authenticate_test.go) asserts the new fallback for ivf_threads_build (int64) and kmeans_train_percent (float64). Approved by: @XuPeng-SH
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #24529
What this PR does / why we need it:
Get too.
becomes complete — but more invasive at session-init time.
Going with the localized fix in GetSessionSysVar as the lowest-risk first step; options 1/2 can follow if the same nil-on-miss pattern bites other call
sites.
Tests
TestGetSessionSysVar_MapMissFallsBackToDefault (pkg/frontend/authenticate_test.go) asserts the new fallback for ivf_threads_build (int64) and
kmeans_train_percent (float64).