Repository navigation
Closed
Labels
Milestone
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Actual Behavior
When creating a branch, inserting data, and immediately merging back to the parent table, a stale read error occurs:
ERROR 22101: CDC handle: stale read
Expected Behavior
Branch merge should succeed without stale read errors after inserting data.
Steps to Reproduce
-- 1. Create branch database
CREATE DATABASE test_mem_branch;
CREATE TABLE `mem_memories` (
`memory_id` varchar(64) NOT NULL,
`user_id` varchar(64) NOT NULL,
`session_id` varchar(64) DEFAULT NULL,
`memory_type` varchar(20) NOT NULL,
`content` text NOT NULL,
`initial_confidence` float NOT NULL,
`trust_tier` varchar(10) DEFAULT NULL,
`embedding` vecf32(384) DEFAULT NULL,
`source_event_ids` json NOT NULL,
`superseded_by` varchar(64) DEFAULT NULL,
`is_active` smallint NOT NULL DEFAULT '1',
`observed_at` datetime(6) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) DEFAULT NULL,
PRIMARY KEY (`memory_id`),
KEY `idx_memory_user_active` (`user_id`,`is_active`),
FULLTEXT `ft_memory_content`(`content`) WITH PARSER ngram,
KEY `idx_memory_observed_at` (`observed_at`),
KEY `idx_memory_superseded_by` (`superseded_by`),
KEY `idx_memory_user_active_type_observed` (`user_id`,`is_active`,`memory_type`,`observed_at`),
KEY `idx_memory_user_type_active` (`user_id`,`memory_type`,`is_active`),
KEY `idx_memory_user_session` (`user_id`,`session_id`),
KEY `idx_memory_embedding` USING ivfflat (`embedding`) lists = 10 op_type 'vector_l2_ops'
);
-- 2. Create branch from parent table
data branch create table test_mem_branch.mem_memories from dev_agent.mem_memories;
-- 3. Insert data into branch
INSERT INTO test_mem_branch.mem_memories
(memory_id, user_id, content, memory_type, trust_tier, is_active,
initial_confidence, source_event_ids, observed_at, created_at, updated_at)
VALUES ('test-mem-001', 'test', 'content', 'semantic', 'T2', 1, 0.8, '[]', NOW(6), NOW(6), NOW(6));
-- 4. Immediately merge back
data branch merge test_mem_branch.mem_memories into dev_agent.mem_memories when conflict accept;Additional information
Error code: 22101
Component: CDC handle
Activity
gouhongshen commentedon Mar 9, 2026
Use this script to reproduce:
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
fix: handle stale read on immediate branch merge after GC (matrixorig…
gouhongshen commentedon Mar 18, 2026
@heni02 Fixed, please help to verify it.
gouhongshen commentedon Mar 26, 2026
#23934
gouhongshen commentedon May 26, 2026
Fixed.