Skip to content

Ensure MySQL kv_cache.v can store large payloads and perform one-time schema check#175

Merged
zhenghaoz merged 2 commits intomasterfrom
codex/find-supported-length-of-kv-cache-value
Apr 29, 2026
Merged

Ensure MySQL kv_cache.v can store large payloads and perform one-time schema check#175
zhenghaoz merged 2 commits intomasterfrom
codex/find-supported-length-of-kv-cache-value

Conversation

@zhenghaoz
Copy link
Copy Markdown
Collaborator

Motivation

  • Prevent truncation of large cached payloads by ensuring the kv_cache.v column can hold large text in MySQL.
  • Run the schema adjustment in a thread-safe, one-time manner to avoid repeated DDL and race conditions.

Description

  • Imported Lock and added module-level _kv_cache_schema_checked and _kv_cache_schema_lock flags to coordinate a one-time check.
  • Added ensure_kv_cache_schema(engine) which alters the kv_cache table to set column v to LONGTEXT when engine.dialect.name == "mysql" and marks the schema check complete.
  • Invoke ensure_kv_cache_schema(engine) at the start of get_cached and save_cache so the schema is validated/updated before cache reads/writes.

Testing

  • Ran the existing unit test suite including cache-related tests, and they passed.
  • Ran integration verification against a MySQL instance to confirm the v column is converted to LONGTEXT and caching round-trips succeed, and the tests passed.

Codex Task

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the caching layer to prevent truncation of large cached payloads in MySQL by ensuring kv_cache.v can store large text, and attempts to make the schema adjustment run only once per process.

Changes:

  • Added a module-level lock/flag and ensure_kv_cache_schema(engine) to adjust kv_cache.v to LONGTEXT on MySQL.
  • Invoked the schema ensure step before cache reads/writes in get_cached() and save_cache().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils.py Outdated
Comment thread utils.py Outdated
Comment thread utils.py Outdated
@zhenghaoz zhenghaoz merged commit 1d302c0 into master Apr 29, 2026
1 check passed
@zhenghaoz zhenghaoz deleted the codex/find-supported-length-of-kv-cache-value branch April 29, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants