If the TiFlash replica is built by library, will newly added tables be automatically synchronized?

Note that this question was originally posted on the Chinese TiDB Forum. We copied it here to help new users solve their problems quickly.

Application environment

POC environment

TiDB version

TiDB v6.1.0

Reproduction method

  1. I built the TiFlash replica by library.
ALTER DATABASE test SET TIFLASH REPLICA 1;
  1. I created a new table in this library and wrote data to it.

  2. I checked the synchronization progress but found that nothing was synchronized to the new table.

SELECT * FROM information_schema.tiflash_replica WHERE TABLE_SCHEMA = 'test';

Problem

I did ALTER DATABASE test SET TIFLASH REPLICA 1 again and it worked. I’m not sure if it’s a bug or an expected result.

After the TiFlash replica is built by library, will the new table be automatically synced?

ALTER DATABASE db_name SET TIFLASH REPLICA count The internal execution of this SQL statement does not guarantee atomicity. By executing this statement, TiDB performs a series of DDL operations for users to add TiFlash replicas to the tables in the database. So it is not certain whether the corresponding DDL operation is executed for the newly added tables during the SQL statement execution.

In addition, TiDB doesn’t automatically set the TiFlash replica for the newly added tables after the SQL statement is executed. Reference doc: Create TiFlash replicas for databases