Repository navigation
Description
Summary
MatrixOne fails a deterministic, single-connection schema bootstrap with:
internal error: materialized sink source reused before all owners released
The failure is returned as error number 20101 and prevents the client from
starting. The workload is sequential (one Astra schema pool with one
connection); there is no concurrent application query or cancellation.
Environment
- MatrixOne commit:
9add8e46c19b40a1a6488ba5d2969d0b380e2083 - standalone quickstart, one TN/CN, MySQL protocol on
127.0.0.1:6001 - Linux amd64
- fresh database,
ASTRA_AUTO_CREATE_DATABASE=1 - Astra schema bootstrap uses a one-connection schema pool and awaits every
statement before issuing the next one
The same failure was observed on the earlier MatrixOne commit
49da1b40cf14c1c7b1d1056a4b611ccbb86158a4.
Reproduction
Build/start the MatrixOne quickstart and run the Astra server against a fresh
database:
ASTRA_DATABASE=astra_materialized_repro \
ASTRA_DATABASE_BOOTSTRAP_CATALOG=mysql \
ASTRA_AUTO_CREATE_DATABASE=1 \
ASTRA_API_HOST=127.0.0.1 ASTRA_API_PORT=17019 \
./target/release/astra-serverThe server exits while bootstrapping the core schema. The final successful
statement is:
CREATE TABLE IF NOT EXISTS conversation_manifest_nodes (
isolation_domain VARCHAR(128) NOT NULL,
owner_user_id VARCHAR(128) NOT NULL,
session_id VARCHAR(128) NOT NULL,
branch_id VARCHAR(128) NOT NULL,
manifest_root CHAR(64) NOT NULL,
parent_manifest_root CHAR(64) NULL,
completed_turn BIGINT NOT NULL,
conversation_seq BIGINT NOT NULL,
compaction_generation BIGINT NOT NULL DEFAULT 0,
canonical_segment_bytes BIGINT NOT NULL,
total_canonical_bytes BIGINT NOT NULL,
total_message_count BIGINT NOT NULL,
reachable TINYINT NOT NULL DEFAULT 0,
manifest_json LONGTEXT NOT NULL,
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
PRIMARY KEY (isolation_domain, owner_user_id, session_id, branch_id, manifest_root),
INDEX idx_context_manifest_parent (isolation_domain, owner_user_id, session_id, branch_id, parent_manifest_root),
INDEX idx_context_manifest_sequence (isolation_domain, owner_user_id, session_id, branch_id, conversation_seq),
INDEX idx_context_manifest_reachable_sequence (isolation_domain, owner_user_id, session_id, branch_id, reachable, conversation_seq),
INDEX idx_context_manifest_generation_sequence (isolation_domain, owner_user_id, session_id, branch_id, compaction_generation, reachable, conversation_seq)
);The next bootstrap operation is an idempotent metadata check of the form:
SELECT 1
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?
LIMIT 1;The client receives:
Database(MySqlDatabaseError {
code: Some("HY000"),
number: 20101,
message: "internal error: materialized sink source reused before all owners released"
})
The fresh database is left with the ordinary tables created so far, but both
astra_schema_contracts and astra_schema_table_contracts remain empty, so
bootstrap never reaches its completion marker.
Evidence of the affected plan shape
On the same server/database, this query is accepted but its plan contains a
shared materialized producer:
EXPLAIN SELECT 1
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'astra_materialized_repro'
AND TABLE_NAME = 'conversation_manifest_nodes'
AND COLUMN_NAME = 'total_canonical_bytes'
LIMIT 1;The output contains:
Plan 0:
-> Table Function on mo_current_roles
Plan 1:
... Sink Scan (DataSource: Plan 0)
... Sink Scan (DataSource: Plan 0)
... Sink Scan (DataSource: Plan 0)
This means a harmless information_schema lookup exercises the multi-reader
materialized-CTE path. The bootstrap is otherwise serial and uses no user CTE.
Relevant implementation
pkg/sql/internal/materialized/source.go rejects Begin when the previous
generation is still active and any producer/reader owner has not released:
if s.active && !s.allReleasedLocked() {
return moerr.NewInternalErrorNoCtx("materialized sink source reused before all owners released")
}pkg/sql/compile/compile.go calls source.Begin before each pipeline run, and
getMaterializedSource creates one source for a materialized CTE with at least
two readers. The observed error therefore means the previous generation's
producer or one of its readers was still owned when the next statement entered
Begin.
Expected behavior
Sequential metadata queries must not fail. MatrixOne should either release all
materialized-CTE owners before the next statement starts, or avoid reusing the
source/compiled plan until the prior generation is fully quiescent. The error
should also include the source generation, reader IDs, statement/trace ID, and
whether producer or reader ownership remained, because the current message is
not sufficient to identify the leaking execution.
I have not reduced this to a single standalone SQL statement yet; the above is a
deterministic integration reproduction from a fresh database, and the
EXPLAIN output identifies the shared materialized system-view plan involved.
Activity
fix(compile): close materialized sources per attempt (#28269)
Ariznawlll commentedon Sep 6, 2026
最新 main 验证结论
main@109bf926fdb31de31e0578ad0fb17be160d7d8d0(2026-09-06)测试步骤
issue_28266数据库和conversation_manifest_nodes表,使用原问题的复合主键、多个索引及LONGTEXT字段形状。SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=? AND TABLE_NAME=? AND COLUMN_NAME=? LIMIT 1issue_28266 / conversation_manifest_nodes / total_canonical_bytes,连续执行两次。DEALLOCATE PREPARE,再查询底表确认连接仍可继续使用。TestPipelineAttemptAlwaysClosesMaterializedSources、TestPipelineAttemptClosesMaterializedSourcesAfterPanic,连续 3 次通过。测试结果
1;20101 internal error: materialized sink source reused before all owners released;MOTR 黑盒用例已加入 motr#146,覆盖同一连接重复执行该 metadata lookup 的场景。
结论
在最新 main 上原问题已验证通过,达到关闭条件,关闭 issue。
fix(compile): close materialized sources per attempt (matrixorigin#28269
fix(compile): close materialized sources per attempt (matrixorigin#28269
fix(compile): close materialized sources per attempt (matrixorigin#28269