mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
Problem: ======= recv_rename_files() replayed the renames in tablespace id order, because renamed_spaces was a std::map keyed by space id that kept only the latest file name per tablespace. A multi-table RENAME such as RENAME TABLE t2 TO t3, t1 TO t2 frees a file name for a tablespace that may have a lower id, and replaying in id order then fails with "Cannot replay rename of tablespace … because the target file exists". Solution: ======== renamed_spaces: Change to a std::vector of (id, from, to), retaining every FILE_RENAME record in log order. The records are appended only while recv_sys.file_checkpoint is set, hence exactly once and in ascending LSN. recv_rename_files(): Replay the records in that order, applying one only when the tablespace currently uses the file name that the record renames from. The order in which the server executed the renames is always replayable, because each rename required its target to be unoccupied.