diff options
author | Monty <monty@mariadb.org> | 2020-05-26 20:04:47 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-05-26 20:05:17 +0300 |
commit | 403dacf6a9a373c25a808a1be9169ab2cd001448 (patch) | |
tree | e4b061147ad60f08636ca231ddf00e03e05e4e06 /sql | |
parent | 0c1f97b3ab7befdae522aaa738be00f6700cee8e (diff) | |
download | mariadb-git-403dacf6a9a373c25a808a1be9169ab2cd001448.tar.gz |
Fixed crash in aria recovery when using bulk insert
MDEV-20578 Got error 126 when executing undo undo_key_delete
upon Aria crash recovery
The crash happens in this scenario:
- Table with unique keys and non unique keys
- Batch insert (LOAD DATA or INSERT ... SELECT) with REPLACE
- Some insert succeeds followed by duplicate key error
In the above scenario the table gets corrupted.
The bug was that we don't generate any undo entry for the
failed insert as the whole insert can be ignored by undo.
The code did however not take into account that when bulk
insert is used, we would write cached keys to the file on
failure and undo would wrongly ignore these.
Fixed by moving the writing of the cache keys after we write
the aborted-insert event to the log.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 13 | ||||
-rw-r--r-- | sql/handler.h | 8 |
2 files changed, 14 insertions, 7 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index d739ce7cd5b..d6e1680143c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4165,6 +4165,19 @@ int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt) /** + End bulk insert +*/ + +int handler::ha_end_bulk_insert() +{ + DBUG_ENTER("handler::ha_end_bulk_insert"); + DBUG_EXECUTE_IF("crash_end_bulk_insert", + { extra(HA_EXTRA_FLUSH) ; DBUG_SUICIDE();}); + estimation_rows_to_insert= 0; + DBUG_RETURN(end_bulk_insert()); +} + +/** Bulk update row: public interface. @sa handler::bulk_update_row() diff --git a/sql/handler.h b/sql/handler.h index a0a43daf144..d1c4b79ee48 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2911,13 +2911,7 @@ public: start_bulk_insert(rows, flags); DBUG_VOID_RETURN; } - int ha_end_bulk_insert() - { - DBUG_ENTER("handler::ha_end_bulk_insert"); - estimation_rows_to_insert= 0; - int ret= end_bulk_insert(); - DBUG_RETURN(ret); - } + int ha_end_bulk_insert(); int ha_bulk_update_row(const uchar *old_data, uchar *new_data, uint *dup_key_found); int ha_delete_all_rows(); |