11/* ****************************************************************************
22
3- Copyright (c) 2017, 2019 , Oracle and/or its affiliates. All Rights Reserved .
3+ Copyright (c) 2017, 2020 , Oracle and/or its affiliates.
44
55Portions of this file contain modifications contributed and copyrighted by
66Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -470,15 +470,32 @@ dberr_t DDL_Log_Table::insert(const DDL_Record &record) {
470470 create_tuple (record);
471471 entry = row_build_index_entry (m_tuple, nullptr , index, m_heap);
472472
473- error = row_ins_clust_index_entry_low (flags, BTR_MODIFY_LEAF, index,
474- index->n_uniq , entry, m_thr, false );
473+ #ifdef UNIV_DEBUG
474+ bool insert = true ;
475+ DBUG_EXECUTE_IF (" ddl_log_return_error_from_insert" , insert = false ;);
476+
477+ if (insert) {
478+ #endif
479+ error = row_ins_clust_index_entry_low (flags, BTR_MODIFY_LEAF, index,
480+ index->n_uniq , entry, m_thr, false );
481+ #ifdef UNIV_DEBUG
482+ } else {
483+ error = DB_ERROR;
484+ }
485+ #endif
475486
476487 if (error == DB_FAIL) {
477488 error = row_ins_clust_index_entry_low (flags, BTR_MODIFY_TREE, index,
478489 index->n_uniq , entry, m_thr, false );
479490 ut_ad (error == DB_SUCCESS);
480491 }
481492
493+ if (error != DB_SUCCESS) {
494+ ib::error (ER_IB_ERR_DDL_LOG_INSERT_FAILURE);
495+ mem_heap_free (offsets_heap);
496+ return error;
497+ }
498+
482499 index = index->next ();
483500
484501 entry = row_build_index_entry (m_tuple, nullptr , index, m_heap);
@@ -860,15 +877,19 @@ dberr_t Log_DDL::write_free_tree_log(trx_t *trx, const dict_index_t *index,
860877 if (is_drop_table) {
861878 /* Drop index case, if committed, will be redo only */
862879 err = insert_free_tree_log (trx, index, id, thread_id);
863- ut_ad (err == DB_SUCCESS);
880+ if (err != DB_SUCCESS) {
881+ return err;
882+ }
864883
865884 DBUG_INJECT_CRASH (" ddl_log_crash_after_free_tree_log" ,
866885 crash_after_free_tree_log_counter++);
867886 } else {
868887 /* This is the case of building index during create table
869888 scenario. The index will be dropped if ddl is rolled back */
870889 err = insert_free_tree_log (nullptr , index, id, thread_id);
871- ut_ad (err == DB_SUCCESS);
890+ if (err != DB_SUCCESS) {
891+ return err;
892+ }
872893
873894 DBUG_INJECT_CRASH (" ddl_log_crash_after_free_tree_log" ,
874895 crash_after_free_tree_log_counter++);
@@ -917,15 +938,14 @@ dberr_t Log_DDL::insert_free_tree_log(trx_t *trx, const dict_index_t *index,
917938 {
918939 DDL_Log_Table ddl_log (trx);
919940 error = ddl_log.insert (record);
920- ut_ad (error == DB_SUCCESS);
921941 }
922942
923943 if (!has_dd_trx) {
924944 trx_commit_for_mysql (trx);
925945 trx_free_for_background (trx);
926946 }
927947
928- if (srv_print_ddl_logs) {
948+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
929949 ib::info (ER_IB_MSG_647) << " DDL log insert : " << record;
930950 }
931951
@@ -955,14 +975,18 @@ dberr_t Log_DDL::write_delete_space_log(trx_t *trx, const dict_table_t *table,
955975 if (is_drop) {
956976 err = insert_delete_space_log (trx, id, thread_id, space_id, file_path,
957977 dict_locked);
958- ut_ad (err == DB_SUCCESS);
978+ if (err != DB_SUCCESS) {
979+ return err;
980+ }
959981
960982 DBUG_INJECT_CRASH (" ddl_log_crash_after_delete_space_log" ,
961983 crash_after_delete_space_log_counter++);
962984 } else {
963985 err = insert_delete_space_log (nullptr , id, thread_id, space_id, file_path,
964986 dict_locked);
965- ut_ad (err == DB_SUCCESS);
987+ if (err != DB_SUCCESS) {
988+ return err;
989+ }
966990
967991 DBUG_INJECT_CRASH (" ddl_log_crash_after_delete_space_log" ,
968992 crash_after_delete_space_log_counter++);
@@ -1014,7 +1038,6 @@ dberr_t Log_DDL::insert_delete_space_log(trx_t *trx, uint64_t id,
10141038 {
10151039 DDL_Log_Table ddl_log (trx);
10161040 error = ddl_log.insert (record);
1017- ut_ad (error == DB_SUCCESS);
10181041 }
10191042
10201043 if (dict_locked) {
@@ -1026,7 +1049,7 @@ dberr_t Log_DDL::insert_delete_space_log(trx_t *trx, uint64_t id,
10261049 trx_free_for_background (trx);
10271050 }
10281051
1029- if (srv_print_ddl_logs) {
1052+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
10301053 ib::info (ER_IB_MSG_648) << " DDL log insert : " << record;
10311054 }
10321055
@@ -1062,11 +1085,16 @@ dberr_t Log_DDL::write_rename_space_log(space_id_t space_id,
10621085
10631086 dberr_t err = insert_rename_space_log (id, thread_id, space_id, old_file_path,
10641087 new_file_path);
1065- ut_ad (err == DB_SUCCESS);
1088+ if (err != DB_SUCCESS) {
1089+ return err;
1090+ }
10661091
10671092 DBUG_INJECT_CRASH (" ddl_log_crash_after_rename_space_log" ,
10681093 crash_after_rename_space_log_counter++);
10691094
1095+ DBUG_EXECUTE_IF (" ddl_log_crash_after_rename_space_log_insert" ,
1096+ DBUG_SUICIDE (););
1097+
10701098 DBUG_EXECUTE_IF (" DDL_Log_remove_inject_error_4" ,
10711099 srv_inject_too_many_concurrent_trxs = true ;);
10721100
@@ -1105,15 +1133,14 @@ dberr_t Log_DDL::insert_rename_space_log(uint64_t id, ulint thread_id,
11051133 {
11061134 DDL_Log_Table ddl_log (trx);
11071135 error = ddl_log.insert (record);
1108- ut_ad (error == DB_SUCCESS);
11091136 }
11101137
11111138 mutex_enter (&dict_sys->mutex );
11121139
11131140 trx_commit_for_mysql (trx);
11141141 trx_free_for_background (trx);
11151142
1116- if (srv_print_ddl_logs) {
1143+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
11171144 ib::info (ER_IB_MSG_649) << " DDL log insert : " << record;
11181145 }
11191146
@@ -1141,7 +1168,9 @@ dberr_t Log_DDL::write_alter_encrypt_space_log(space_id_t space_id) {
11411168 crash_before_alter_encrypt_space_log_counter++);
11421169
11431170 dberr_t err = insert_alter_encrypt_space_log (id, thread_id, space_id);
1144- ut_ad (err == DB_SUCCESS);
1171+ if (err != DB_SUCCESS) {
1172+ return err;
1173+ }
11451174
11461175 DBUG_INJECT_CRASH (" ddl_log_crash_after_alter_encrypt_space_log" ,
11471176 crash_after_alter_encrypt_space_log_counter++);
@@ -1168,15 +1197,14 @@ dberr_t Log_DDL::insert_alter_encrypt_space_log(uint64_t id, ulint thread_id,
11681197 {
11691198 DDL_Log_Table ddl_log (trx);
11701199 error = ddl_log.insert (record);
1171- ut_ad (error == DB_SUCCESS);
11721200 }
11731201
11741202 mutex_enter (&dict_sys->mutex );
11751203
11761204 trx_commit_for_mysql (trx);
11771205 trx_free_for_background (trx);
11781206
1179- if (srv_print_ddl_logs) {
1207+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
11801208 ib::info (ER_IB_MSG_1284) << " DDL log insert : " << record;
11811209 }
11821210
@@ -1198,7 +1226,9 @@ dberr_t Log_DDL::write_drop_log(trx_t *trx, const table_id_t table_id) {
11981226
11991227 dberr_t err;
12001228 err = insert_drop_log (trx, id, thread_id, table_id);
1201- ut_ad (err == DB_SUCCESS);
1229+ if (err != DB_SUCCESS) {
1230+ return err;
1231+ }
12021232
12031233 DBUG_INJECT_CRASH (" ddl_log_crash_after_drop_log" ,
12041234 crash_after_drop_log_counter++);
@@ -1225,12 +1255,11 @@ dberr_t Log_DDL::insert_drop_log(trx_t *trx, uint64_t id, ulint thread_id,
12251255 {
12261256 DDL_Log_Table ddl_log (trx);
12271257 error = ddl_log.insert (record);
1228- ut_ad (error == DB_SUCCESS);
12291258 }
12301259
12311260 mutex_enter (&dict_sys->mutex );
12321261
1233- if (srv_print_ddl_logs) {
1262+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
12341263 ib::info (ER_IB_MSG_650) << " DDL log insert : " << record;
12351264 }
12361265
@@ -1253,7 +1282,9 @@ dberr_t Log_DDL::write_rename_table_log(dict_table_t *table,
12531282
12541283 dberr_t err =
12551284 insert_rename_table_log (id, thread_id, table->id , old_name, new_name);
1256- ut_ad (err == DB_SUCCESS);
1285+ if (err != DB_SUCCESS) {
1286+ return err;
1287+ }
12571288
12581289 DBUG_EXECUTE_IF (" DDL_Log_remove_inject_error_5" ,
12591290 srv_inject_too_many_concurrent_trxs = true ;);
@@ -1290,15 +1321,14 @@ dberr_t Log_DDL::insert_rename_table_log(uint64_t id, ulint thread_id,
12901321 {
12911322 DDL_Log_Table ddl_log (trx);
12921323 error = ddl_log.insert (record);
1293- ut_ad (error == DB_SUCCESS);
12941324 }
12951325
12961326 mutex_enter (&dict_sys->mutex );
12971327
12981328 trx_commit_for_mysql (trx);
12991329 trx_free_for_background (trx);
13001330
1301- if (srv_print_ddl_logs) {
1331+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
13021332 ib::info (ER_IB_MSG_651) << " DDL log insert : " << record;
13031333 }
13041334
@@ -1319,7 +1349,9 @@ dberr_t Log_DDL::write_remove_cache_log(trx_t *trx, dict_table_t *table) {
13191349
13201350 dberr_t err =
13211351 insert_remove_cache_log (id, thread_id, table->id , table->name .m_name );
1322- ut_ad (err == DB_SUCCESS);
1352+ if (err != DB_SUCCESS) {
1353+ return err;
1354+ }
13231355
13241356 DBUG_EXECUTE_IF (" DDL_Log_remove_inject_error_3" ,
13251357 srv_inject_too_many_concurrent_trxs = true ;);
@@ -1351,13 +1383,12 @@ dberr_t Log_DDL::insert_remove_cache_log(uint64_t id, ulint thread_id,
13511383 {
13521384 DDL_Log_Table ddl_log (trx);
13531385 error = ddl_log.insert (record);
1354- ut_ad (error == DB_SUCCESS);
13551386 }
13561387
13571388 trx_commit_for_mysql (trx);
13581389 trx_free_for_background (trx);
13591390
1360- if (srv_print_ddl_logs) {
1391+ if (error == DB_SUCCESS && srv_print_ddl_logs) {
13611392 ib::info (ER_IB_MSG_652) << " DDL log insert : " << record;
13621393 }
13631394
0 commit comments