Skip to content

[Bug]: Python Pinecone index handle uses stale metadata after ALTER TABLE #31228

Closed

Description

@Ariznawlll

Description

A long-lived Python SDK PineconeCompatibleIndex object caches the table's metadata columns indefinitely. After ALTER TABLE adds a metadata column, query() silently omits it. After ALTER TABLE drops a cached metadata column, the same index object keeps selecting the removed column and every query fails. Both sync and async clients are affected, even though the vector index and base data remain valid.

Environment

  • Branch: main
  • Commit: 5fe08a3307e246e1ab9951ab690b50557af0f509
  • Deployment: isolated MatrixOne 8.0.30-MatrixOne-v1.3.0, Python 3.11, MatrixOne Python SDK 0.1.16

Steps to reproduce

CREATE TABLE docs(id INT PRIMARY KEY, title VARCHAR(30), v VECF32(2));
INSERT INTO docs VALUES (1,'alpha','[1,1]'),(2,'beta','[2,0]');
SET experimental_ivf_index=1;
CREATE INDEX idx_docs USING ivfflat ON docs(v) LISTS 1 op_type 'vector_l2_ops';
idx = client.get_pinecone_index('docs', 'v')
idx.query([1,1], top_k=2)       # warm column cache: ['title']
client.execute("ALTER TABLE docs ADD COLUMN tag VARCHAR(30) DEFAULT 'new'")
print(idx.query([1,1], top_k=2).matches[0].metadata)
# Actual: {'id': 1, 'title': 'alpha'}; tag is missing.
# Fresh get_pinecone_index(...).query(...) includes tag='new'.

client.execute("ALTER TABLE docs DROP COLUMN title")
idx.query([1,1], top_k=2)
# Actual: QueryError / column title does not exist.
# Fresh get_pinecone_index(...).query(...) succeeds and returns both rows.

query_async() has the same stale-cache behavior.

Actual behavior

  • Post-ADD: existing index object silently returns incomplete metadata even though SELECT id,title,tag confirms the new column and value.
  • Post-DROP: existing object generates SELECT id, title, l2_distance(v, '[1,1]') ..., which fails with 1054 column title does not exist.
  • A newly created SDK index object immediately returns the correct post-DDL metadata and results.

Expected behavior

Search should continue working after metadata-column DDL and return the current metadata schema, without requiring callers to discard and recreate an index object. If schema caching is required, the SDK should detect staleness and refresh before or after an invalid-column error.

Stability and controls

  • Sync: 3/3 independent newly created IVF-indexed tables reproduced both silent omission and query failure.
  • Async: 3/3 further independent newly created tables reproduced the same.
  • Direct SQL after each DDL confirms current schema, correct two rows, and tag='new'; fresh SDK handles also query successfully, so the backend index and data are healthy.
  • After the old-handle failure, the connection remains usable and row count remains 2; fresh-handle query returns both rows.
  • Searched all-state MatrixOne issues for Pinecone/schema-cache/ALTER combinations; no matching issue found. This differs from [Bug]: Python SDK selects the wrong vector index on multi-vector-column tables #31223, which misidentifies an index on a multi-vector-column table before any DDL.

Evidence

  • Sync reproducer: /private/tmp/mo-sdk-index-20261026/probe_vector_schema_cache_3run.py
  • Async reproducer: /private/tmp/mo-sdk-index-20261026/probe_vector_schema_cache_async_3run.py
  • Exact selected output: /private/tmp/mo-sdk-index-20261026/vector_schema_cache_3run.log

Code analysis

PineconeCompatibleIndex._get_metadata_columns() and its async counterpart return _metadata_columns immediately after the first DESCRIBE, with no invalidation or schema-version check. query() and query_async() use this cached list to build each SELECT.

Regression coverage

Add sync/async SDK tests that warm an index object's metadata cache, ALTER ADD and DROP a metadata column, then query with the same object. Assert exact post-DDL metadata, absence of removed-column errors, row count and continued usability. No repository test was added during exploration.

Activity

  1. added this to the MO-202610 milestone on Oct 26, 2026
  2. added
    kind/bug
    on Oct 26, 2026
  3. added theissue type on Oct 26, 2026
  4. added a commit that references this issue on Oct 26, 2026
    28e8760
  5. XuPeng-SH commented on Oct 26, 2026

    @XuPeng-SH
    Contributor

    Local SDK QA (2026-10-26): SDK source 28e8760905a7f39dba2ce436357ea75492f30512; isolated MatrixOne service binary 83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3 (SHA-256 6bebe05311ae6438967a824641e3849fbbc9af298003177351794601edf14b4b). Passed tests/online/test_sdk_search_contracts.py::test_vector_metric_filters_and_live_schema in sync and async modes. A long-lived Pinecone index handle returned the newly added tag='new' metadata after ALTER ADD COLUMN and omitted the field after ALTER DROP COLUMN; the table retained all three rows. This directly tests metadata refresh on schema changes.

  6. Ariznawlll commented on Oct 27, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 官方 main:420786e21566e5b9d5875e7d6a7f3102fd0761af;修复 PR fix(python-sdk): unify query contracts and atomic manager operations #31262 已 MERGED,merge commit 28e8760905a7f39dba2ce436357ea75492f30512 是该 main 的祖先。
    • 隔离本地部署:从上述 SHA 重建的 1 LOG / 1 TN / 2 CN,SQL 47011/47012;Python 3.12、SQLAlchemy 2.0.55、同工作树 Python SDK。二进制 SHA-256:8bd0f1f4c60cd0590c68cdbb2cbca31fc9d39d071ec367ab56d5c49b4eec327e。
    • 测试日期:2026-10-27。

    原问题验证

    原始 Pinecone handle 缓存旧表结构。建立 handle 后 ALTER TABLE ADD COLUMN tag VARCHAR(20) DEFAULT 'new',不重新获取 handle 即查询,所有 match 的 metadata 均含 tag='new';随后 DROP COLUMN tag,同一 handle 再查询均不含 tag。同步/异步、cosine/ip 组合各 3/3 通过。

    Happy Path 覆盖

    1. 另一向量列 other 的索引元数据仍为 L2,说明 schema 刷新没有混淆列;主索引查询顺序/score 与原生 SQL 一致。
    2. 四个在线 SDK 合同文件连续 3 轮,每轮 70/70 通过,零失败、错误、跳过;另有 112 项定向离线合同连续 3 轮通过。未运行全量 SDK suite 或 race。fix(python-sdk): unify query contracts and atomic manager operations #31262 六个离线 SDK CI job 成功,在线 CI 为 SKIPPED,在线结论以本地实跑为准。

    Unhappy Path 覆盖

    1. 非法过滤运算符抛 ValueError,底表三行保留;删列后不会在结果里泄漏已删除的 tag。

    白盒验证

    本轮直接运行公开 SDK API 的在线合同并核对测试源码中的断言与真实服务端行集/连接状态;未修改产品源码。

    回归测试

    #31262 已包含 clients/python/tests/online/test_sdk_search_contracts.py::test_vector_metric_filters_and_live_schema[cosine/ip × sync/async]。 SDK 行为无法由纯 SQL MOTR 代替,本轮未新增 MO 或 MOTR PR。

    测试证据

    本地 JUnit:/private/tmp/mo-six-qa-20261026/qa-night/sdk-contract-round-{1,2,3}.xml,每轮 tests=70,failures=0,errors=0,skipped=0。修复 PR:#31262 。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions