You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(storage): repair call log columns in versioned user databases - #283
Upgrading a user database created before #258 can leave mem_api_call_log without tool_success and tool_error_kind. Those columns were added while the user schema version remained 2, so migrate_user() returns early for existing version-2 databases. The new call-log writer then fails to insert monitoring entries, and call-statistics queries fail on the missing columns.
Check and repair the two nullable columns before the current-version fast path returns, and reuse the repair in the older-schema migration path. Existing columns are skipped. The ALTER statements use the existing bounded MatrixOne transaction retry helper; duplicate-column errors are harmless, and a secondary-index DDL race is accepted only if the requested column now exists.
For an otherwise usable version-2 database, failure of this optional monitoring repair is logged and does not block memory reads or writes. The background call-log writer retries schema repair on subsequent batches, including through already-cached user stores. A per-store success hint avoids repeated metadata queries after repair; failures remain retryable. As with existing failed call-log inserts, batches whose schema repair fails are dropped with a warning; they are not retained in an unbounded queue. Call statistics remain degraded until the log table can be repaired.
Keep the version marker unchanged for already-current databases. This targeted repair avoids replaying unrelated historical memory/branch migrations and remains compatible with old API instances during a rolling update: old writers omit these nullable columns, and historical rows retain NULL outcomes. User migration remains lazy, triggered when the database is opened.
Validation
Reproduced the original missing-column defect on the unmodified base.
Five SQL integration regressions passed on an isolated MatrixOne 4.2.1-d2393868a instance: version 1 and version 2, partial repair, concurrent instances, and a logging failure followed by recovery on the same cached store. They verify preserved history and memories, old/new writer compatibility, usable statistics, and idempotent reentry. Successful fixtures remove their owned shared/user databases.
API end-to-end regression verifies memory writes and reads during a logging outage, followed by background schema repair, tool-outcome persistence, and working call statistics without cache invalidation.
Existing API end-to-end tool-outcome persistence regression also verified.
Storage/API library tests: 157 passed, 1 existing explicit DB test ignored. Strict Clippy for both libraries plus the new storage integration target passed with -D warnings. Strict Clippy of the entire existing API e2e target additionally exposes pre-existing type_complexity and to_string_in_format_args warnings outside this change.
Changed-line formatting and git diff --check passed.
No production schema changes or deployment were performed.
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
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
Follow-up to #258; no linked issue.
What this PR does / why we need it
Upgrading a user database created before #258 can leave
mem_api_call_logwithouttool_successandtool_error_kind. Those columns were added while the user schema version remained 2, somigrate_user()returns early for existing version-2 databases. The new call-log writer then fails to insert monitoring entries, and call-statistics queries fail on the missing columns.Check and repair the two nullable columns before the current-version fast path returns, and reuse the repair in the older-schema migration path. Existing columns are skipped. The ALTER statements use the existing bounded MatrixOne transaction retry helper; duplicate-column errors are harmless, and a secondary-index DDL race is accepted only if the requested column now exists.
For an otherwise usable version-2 database, failure of this optional monitoring repair is logged and does not block memory reads or writes. The background call-log writer retries schema repair on subsequent batches, including through already-cached user stores. A per-store success hint avoids repeated metadata queries after repair; failures remain retryable. As with existing failed call-log inserts, batches whose schema repair fails are dropped with a warning; they are not retained in an unbounded queue. Call statistics remain degraded until the log table can be repaired.
Keep the version marker unchanged for already-current databases. This targeted repair avoids replaying unrelated historical memory/branch migrations and remains compatible with old API instances during a rolling update: old writers omit these nullable columns, and historical rows retain NULL outcomes. User migration remains lazy, triggered when the database is opened.
Validation
4.2.1-d2393868ainstance: version 1 and version 2, partial repair, concurrent instances, and a logging failure followed by recovery on the same cached store. They verify preserved history and memories, old/new writer compatibility, usable statistics, and idempotent reentry. Successful fixtures remove their owned shared/user databases.-D warnings. Strict Clippy of the entire existing API e2e target additionally exposes pre-existingtype_complexityandto_string_in_format_argswarnings outside this change.git diff --checkpassed.No production schema changes or deployment were performed.