Skip to content

fix(query): scope HTTP session state by tenant#19931

Open
3em0 wants to merge 2 commits into
databendlabs:mainfrom
3em0:fix-tenant-scoped-http-session-state
Open

fix(query): scope HTTP session state by tenant#19931
3em0 wants to merge 2 commits into
databendlabs:mainfrom
3em0:fix-tenant-scoped-http-session-state

Conversation

@3em0

@3em0 3em0 commented May 27, 2026

Copy link
Copy Markdown

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • Scope HTTP temporary-table session state by tenant so sessions from different tenants no longer share the same user/client_session_id in-memory key.
  • Reuse the same tenant-scoped prefix for HTTP temporary-table registration, refresh, restore, and cleanup.
  • Keep the existing MySQL temporary-table prefix format unchanged.

Fixes #19930

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - cargo/Rust toolchain is not installed in this environment, so I could not execute the added unit tests locally. I ran git diff --check successfully.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions Bot added the pr-bugfix this PR patches a bug in codebase label May 27, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26f82c14a7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

user_name: &str,
session_id: &str,
) -> String {
format!("{}/{user_name}/{session_id}", tenant.tenant_name())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update temporary table key consumers for tenant prefix

When an HTTP temp table exists, ClientSessionManager::get_all_temp_tables() now returns keys built by this helper, but system.temporary_tables still decodes every key as user/session_id (temporary_tables_table.rs lines 120-121). With the new tenant/user/session_id format, that table reports the tenant as the user and the user name as the session id, so is_current_session also never matches the real client session id for HTTP sessions. Please update the HTTP parsing/display path or keep the tenant-scoped map key separate from the two-part session key exposed to this table.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3em0 thanks for your contribution. this does need to be fixed

@sundy-li sundy-li requested a review from youngsofun May 27, 2026 13:15
@github-actions

Copy link
Copy Markdown
Contributor

🤖 CI Job Analysis

Workflow: 26513223946

📊 Summary

  • Total Jobs: 28
  • Failed Jobs: 2
  • Retryable: 0
  • Code Issues: 2

NO RETRY NEEDED

All failures appear to be code/test issues requiring manual fixes.

🔍 Job Details

  • mac_check: Not retryable (Code/Test)
  • linux / check: Not retryable (Code/Test)

🤖 About

Automated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed).

@3em0

3em0 commented Jun 1, 2026

Copy link
Copy Markdown
Author

sorry! i am late to fix it

@youngsofun

Copy link
Copy Markdown
Member

@3em0 need pass check to start tests.

Resolve `clippy::items_after_test_module` errors that failed the
linux/check and mac_check CI jobs by moving the items declared after
the `#[cfg(test)] mod tests` blocks to before them, so each test
module is the last item in its file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Databend HTTP Client Session State Key Collision

2 participants