Skip to content

bug: OceanBase long queries fail with lexical-coverage expression overflow #2016

Closed

Description

@Zxf-xufeng

Describe the bug

Atomic Memory text search on OceanBase can fail for queries within the supported 8,192-character limit. The lexical-coverage predicate builds a flat sum of one CASE expression per analyzed term. With sufficiently many terms, OceanBase returns 4019: Size overflow, which surfaces as HTTP 500.

Both public search routes are affected:

  • /v1/scopes/{scope_id}/artifacts/atomic-memory/search
  • /v1/atomic-memory/search

This is a standalone follow-up to the reviews of #1882. The final review confirmed that the defect also existed in that PR's base; it is not a new regression introduced by #1882.

Evidence:

Steps to reproduce

  1. Start PowerContext with an OceanBase backend and an authorized scope.

  2. Construct the following text:

    query = " ".join(f"term{i}" for i in range(1000))
    assert len(query) == 7889
  3. Remember an Atomic Memory containing that text in the scope.

  4. Search for the same text in text mode through each of the two public routes listed above, using the scope's normal authentication and request fields.

  5. Compare with a short, 10-term query as a control.

The original review also reproduced the failure with a 600-character CJK query. Its exact input was not included in the linked review, so the ASCII input above is the fully specified reproduction case in this report.

Expected behavior

Supported queries should succeed and return matching memories. The implementation must preserve all analyzed terms and the configured admission threshold; truncating terms or removing lexical coverage would change retrieval semantics.

Regression coverage should exercise both public routes against real OceanBase, including many-term ASCII and CJK inputs. The MySQL recovery probe in atomic_memory_index.py also constructs a flat sum and should be checked for the same limitation.

Actual behavior

Both routes return HTTP 500 with OceanBase error 4019: Size overflow for the supported long ASCII input. The reported CJK input also fails, while a 10-term control succeeds.

The linked review compared SQL against the same actual table: native FULLTEXT alone succeeded, the flat coverage predicate failed, and replacing only the addition tree with a balanced expression succeeded while retaining the admission filter. This isolates expression shape as a useful fix direction; it does not justify removing coverage.

Environment

  • Database in the original reproduction: OceanBase CE 4.3.5.4.
  • Last reviewed PR head: b402e590ab9244897d91123fc482e0c0cc770a9a.
  • Base where the same defect was confirmed: a72f223b88a341162618686a404e29d5f2290994.
  • The flat expression was also found during post-merge inspection of master on October 15, 2026.
  • Python and operating-system versions were not specified in the linked review.
  • This report was drafted with OpenAI Codex from the linked reproduction evidence and source inspection. No new backend reproduction was run while filing it.

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions