[MDEV-24746] Atomic CREATE TRIGGER Created: 2021-01-31  Updated: 2022-11-01  Resolved: 2021-05-20

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

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

Issue Links:
PartOf
is part of MDEV-17567 Atomic DDL Closed

 Description   

The purpose of this task is to ensure that CREATE TRIGGER is atomic

When a trigger is created, we first create a trigger_name.TRN file and then
create or update the table_name.TRG files.
This is done by creating .TRN~ and .TRG~ files and replacing (or creating)
the result files.

The new logic is

  • Log CREATE TRIGGER to DDL log, with a marker if old trigger existsted
  • If old .TRN or .TRG files exists, make backup copies of these
  • Create the new .TRN and .TRG files as before
  • Remove the backups

Crash recovery

  • If query has been logged to binary log:
  • delete any left over backup files
  • else
  • Delete any old .TRN~ or .TRG~ files
  • If there was orignally some triggers (old .TRG file existed)
  • If we crashed before creating all backup files
  • Delete existing backup files
  • else
  • Restore backup files
  • end
  • Delete .TRN and .TRG file (as there was no triggers before

One benefit of the new code is that CREATE OR REPLACE TRIGGER is now
totally atomic even if there existed an old trigger: Either the old
trigger will be replaced or the old one will be left untouched.



 Comments   
Comment by Michael Widenius [ 2021-01-31 ]

Pushed into bb-10.6-monty

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