mview: CREATE MATERIALIZED VIEW LOG without PURGE NEXT is accepted
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
### 1. Minimal reproduce step (Required)
On a TiDB cluster, run:
~~~sql
DROP DATABASE IF EXISTS mlog_purge_repro;
CREATE DATABASE mlog_purge_repro;
USE mlog_purge_repro;
CREATE TABLE t_base (
id INT PRIMARY KEY,
v INT
);
CREATE MATERIALIZED VIEW LOG ON t_base (id, v);
SELECT *
FROM mysql.tidb_mlog_purge_info;
~~~
The MLog metadata can then be inspected for the MLog created on t_base.
### 2. What did you expect to see? (Required)
According to the Stage 3 MView contract, an MLog must define an automatic purge schedule with a NEXT time. A bare MLog DDL that omits the PURGE/NEXT clause should therefore be rejected with a clear error, and no MLog should be created.
### 3. What did you see instead (Required)
The bare MLog DDL succeeds and creates the MLog. Its purge metadata has no next scheduled time: mysql.tidb_mlog_purge_info.NEXT_TIME is NULL. As a result, this MLog does not enter the automatic purge scheduler.
This is different from #66797, which covers an explicit PURGE IMMEDIATE statement being rejected; this issue covers omission of the entire PURGE/NEXT clause.
### 4. What is your TiDB version? (Required)
The issue was reproduced directly on 2026-08-07 with:
~~~text
Release Version: v8.5.4-20260801-4572f61
Edition: Enterprise
Git Commit Hash: 4572f61eeee5ca022ad73d8fcd7595e012247b8
~~~
Contributor guide
Research direction
Start by running the minimal SQL reproduction on a TiDB cluster and inspect mysql.tidb_mlog_purge_info, especially NEXT_TIME. Trace the CREATE MATERIALIZED VIEW LOG handling and its validation of PURGE/NEXT clauses; done means the bare statement is rejected with a clear error and creates no MLog.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100