[Bug]: Prepared SHOW TABLES/TABLE STATUS keeps stale plan after database becomes a subscription

Aperta
#33,368 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@matrix-meow ci sta già lavorando.

Dal 27/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

kind/bug needs-triage

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Searched open and closed issues for prepared SHOW TABLES/TABLE STATUS, subscription databases, stale plans, and publication lifecycle. #20596/#20584 cover direct SHOW TABLE STATUS errors for subscription databases, and #30948 covers a zombie database after DROP PUBLICATION. In this reproduction direct and fresh statements both work; only the old prepared statement is stale.

Branch Name

main

Commit ID

c0cef5c9cce2164fedd201c188bfffe4d2d09a96

A read-only check of main snapshot 9bf005bfcd06ef722351bccd9c9a59833ce2b5bd found the relevant PREPARE/SHOW function bodies unchanged. Runtime reproduction is against the commit above.

Other Environment Information

  • Hardware parameters: single-CN local deployment
  • OS type: macOS
  • Others: two subscriber sessions plus the sys publication owner; direct SQL and fresh PREPARE are the correctness controls

Actual Behavior

When an ordinary database is dropped and replaced by a same-name subscription database, old prepared SHOW TABLES and SHOW TABLE STATUS handles continue using the old ordinary-database plan and return empty result sets. Direct SHOW and freshly prepared statements in the same session both return the published table.

Expected Behavior

Changing the database identity or subscription route should invalidate and rebuild the prepared statement. At minimum, old EXECUTE should see the same current published table as direct SHOW and a fresh PREPARE, rather than silently returning an empty set.

Steps to Reproduce

-- As sys:root
CREATE DATABASE pub_db;
CREATE TABLE pub_db.pub_t(id INT PRIMARY KEY);
CREATE ACCOUNT sub ADMIN_NAME='root' IDENTIFIED BY '111';
CREATE PUBLICATION pub DATABASE pub_db TABLE pub_t ACCOUNT sub;

-- Open sessions S1 and S2 as sub:root
-- S1
CREATE DATABASE home_db;
CREATE DATABASE alias;
CREATE TABLE alias.local_t(id INT PRIMARY KEY);
USE home_db;
PREPARE p_tables FROM 'SHOW TABLES FROM alias';
PREPARE p_status FROM 'SHOW TABLE STATUS FROM alias';
EXECUTE p_tables;  -- local_t
EXECUTE p_status;  -- local_t

-- S2, with autocommit enabled
DROP DATABASE alias;
CREATE DATABASE alias FROM sys PUBLICATION pub;

-- S1
EXECUTE p_tables;  -- actual: success, zero rows
EXECUTE p_status;  -- actual: success, zero rows

The initial executions intentionally warm both prepared-plan reuse paths before the cross-session database replacement.

Controls

In S1 immediately after the stale executions:

SHOW TABLES FROM alias;        -- pub_t
SHOW TABLE STATUS FROM alias;  -- pub_t

PREPARE fresh_tables FROM 'SHOW TABLES FROM alias';
EXECUTE fresh_tables;          -- pub_t
PREPARE fresh_status FROM 'SHOW TABLE STATUS FROM alias';
EXECUTE fresh_status;          -- pub_t

Thus the subscription is not empty and direct subscription metadata handling is working. Two independent MatrixOne processes reproduced the complete old/direct/fresh comparison in two 31-event runs, including successful cleanup of the subscription database, publication, and temporary account.

Additional information

buildShowTables and buildShowTableStatus bake the database route into their rewritten queries at plan-build time. After the ordinary-to-subscription transition, the old prepared plans retain the ordinary-database route, while fresh plans resolve the current subscription metadata. The database identity/subscription change does not invalidate those old plans.

Lingua principale
Go
Stelle
1.9k
Fork
312
Merge medio
21h 57m
PR unite (30g)
730

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di matrixorigin/matrixone

Tutte le issue di matrixorigin/matrixone

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.