Repository navigation
Description
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,tagconfirms the new column and value. - Post-DROP: existing object generates
SELECT id, title, l2_distance(v, '[1,1]') ..., which fails with1054 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
fix(python-sdk): unify query contracts and atomic manager operations (#…
XuPeng-SH commentedon Oct 26, 2026
Local SDK QA (2026-10-26): SDK source
28e8760905a7f39dba2ce436357ea75492f30512; isolated MatrixOne service binary83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3(SHA-2566bebe05311ae6438967a824641e3849fbbc9af298003177351794601edf14b4b). Passedtests/online/test_sdk_search_contracts.py::test_vector_metric_filters_and_live_schemain sync and async modes. A long-lived Pinecone index handle returned the newly addedtag='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.Ariznawlll commentedon Oct 27, 2026
测试版本
420786e21566e5b9d5875e7d6a7f3102fd0761af;修复 PR fix(python-sdk): unify query contracts and atomic manager operations #31262 已 MERGED,merge commit28e8760905a7f39dba2ce436357ea75492f30512是该 main 的祖先。8bd0f1f4c60cd0590c68cdbb2cbca31fc9d39d071ec367ab56d5c49b4eec327e。原问题验证
原始 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 覆盖
other的索引元数据仍为 L2,说明 schema 刷新没有混淆列;主索引查询顺序/score 与原生 SQL 一致。Unhappy Path 覆盖
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 。测试结论
测试通过。