[MDEV-24408] Crash-safe DROP DATABASE Created: 2020-12-15  Updated: 2022-11-01  Resolved: 2021-05-20

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table
Fix Version/s: 10.6.1

Type: Task Priority: Critical
Reporter: Michael Widenius Assignee: Michael Widenius
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
PartOf
is part of MDEV-17567 Atomic DDL Closed
Relates
relates to MDEV-25506 Atomic DDL: .frm file is removed and ... Closed
relates to MDEV-25691 Simplify handlerton::drop_database fo... Closed
relates to MDEV-25920 Atomic DROP DATABASE Open

 Description   

The purpose of this task is to ensure that DROP DATABASE is crash safe.

This means that if the server is killed during drop database crashes , the database and binary log will be consistent when the server has done engine and ddl recovery.
All tables that where already dropped or started to be dropped will be fully dropped and binary logged.
Before this task there was a change that one could, after a crash, have stray .frm files
and dropped tables was not binary logged.

For this particular project, we will ensure that every executed DROP TABLE is atomic and will be logged to the binary log.

This is the same behaviour that we have with multi-table DROP TABLE.
Making DROP DATABASE atomic (either everything is dropped or nothing) will be fixed in a future task.

Description of how the current task should work:

  • Collect list of tables
  • DDL log tables as they are dropped
  • DDL log drop database
  • Delete db.opt
  • Delete data directory
  • Deactive ddl log entry

This is in line of how things are now (minus ddl logging) except that
we delete db.opt file last to not loose it if DROP DATABASE fails.

On recovery we have to ensure that all dropped tables are logged in
binary log and that they are properly dropped (as with atomic drop
table).
No new tables be dropped as part of recovery.

Recovery of active drop database ddl log entry:

  • Update binary log with dropped tables. If table list is longer than
    max_allowed_packet, then the query will be split into multiple drop queries.
  • If drop database was ddl logged but not in binary log
  • drop the db.opt file and database directory.
  • Log into the binary log


 Comments   
Comment by Marko Mäkelä [ 2021-05-17 ]

I feel that handlerton::drop_database is largely redundant after MDEV-25506 and other changes. It would be invoked as a last clean-up step to remove any garbage that could have been left behind in InnoDB.

However, in a future implementation of atomic or transactional DROP DATABASE, the simplified InnoDB implementation of handlerton::drop_database could come in handy. The operation probably should be two-phase: first check with each storage engine that the operation would succeed, and then commit to performing it.

Generated at Thu Feb 08 09:29:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.