Skip to content

fix(sessions): use LONGTEXT for MySQL message storage - #4910

Draft
rioyu123 wants to merge 1 commit into
openai:mainfrom
rioyu123:codex/mysql-session-longtext
Draft

fix(sessions): use LONGTEXT for MySQL message storage#4910
rioyu123 wants to merge 1 commit into
openai:mainfrom
rioyu123:codex/mysql-session-longtext

Conversation

@rioyu123

@rioyu123 rioyu123 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This pull request changes the message_data column to LONGTEXT for newly created MySQL and MariaDB message tables. Other dialects retain TEXT; serialization, session identifiers, transactions, and public APIs are unchanged. Existing tables are not migrated.

MySQL-family TEXT storage is too small for some serialized session items. In a live example, Chinese/emoji content serialized to 1,200,028 bytes: strict mode rejected the TEXT insert with error 1406, while non-strict mode logged truncation and stored 65,535 bytes of invalid JSON that the SDK could not return as the original item. A LONGTEXT column preserved the full item through SDK add/get/pop in both modes.

Draft dependency: current main cannot automatically create these MySQL/MariaDB tables because the session_id columns use an unbounded String. #4741, an open PR from another contributor, proposes fixing that separate problem. This PR contains none of its changes and does not independently restore automatic table creation. It is open as a draft to discuss the column-capacity change while the schema-creation work is reviewed. Users who already manage their own LONGTEXT schema do not need this patch.

Before marking this ready, I will refresh against the accepted schema-creation baseline, verify the combined automatic-create and large-item path, and finish the final review and verification gates.

Test plan

  • tests/extensions/memory/test_sqlalchemy_session.py: 47 passed, including four new column-compilation cases for MySQL, MariaDB, PostgreSQL, and SQLite.
  • Ruff check and format check passed for both changed files; git diff --check passed.
  • Real MySQL 8.0.46 and MariaDB 11.8.9, using caller-managed tables and SQLAlchemySession(create_tables=False): small-item controls passed; strict TEXT raised error 1406; non-strict TEXT produced truncated, invalid JSON; LONGTEXT preserved the complete 1,200,028-byte serialized value and exact SDK get/pop results in both modes.
  • Offline complete-table compilation: current main plus this change still fails on unbounded session_id; fix(sessions): support MySQL and MariaDB schema creation #4741's schema plus the proposed column type compiles for both MySQL and MariaDB. This was a disposable metadata composition check, not a combined-source live automatic-creation test.
  • The full repository verification stack and final schema-change review are still pending for this early draft. No full-stack pass is claimed.

Issue number

N/A. Related schema-creation work: #4741.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants