Skip to content

Commit 466d9f5

Browse files
committed
MDEV-32103 InnoDB ALTER TABLE is not crash-safe
Starting with commit 4ff5311 log_write_up_to(trx->commit_lsn, true) in DDL operations could end up being a no-op, because trx->commit_lsn would be 0. trx_flush_log_if_needed(): Revert an incorrect attempt to ensure that DDL operations are crash-safe. trx_t::commit(std::vector<pfs_os_file_t> &), ha_innobase::rename_table(): Set trx_t::flush_log_later so that trx_t::commit_in_memory() will retain trx_t::commit_lsn for the final durability call. Tested by: Matthias Leich
1 parent 4a8291f commit 466d9f5

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

storage/innobase/dict/drop.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ dberr_t trx_t::drop_table(const dict_table_t &table)
235235
void trx_t::commit(std::vector<pfs_os_file_t> &deleted)
236236
{
237237
ut_ad(dict_operation);
238+
flush_log_later= true;
238239
commit_persist();
240+
flush_log_later= false;
239241
if (dict_operation)
240242
{
241243
std::vector<uint32_t> space_ids;

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14263,6 +14263,7 @@ ha_innobase::rename_table(
1426314263
}
1426414264

1426514265
if (error == DB_SUCCESS) {
14266+
trx->flush_log_later = true;
1426614267
innobase_commit_low(trx);
1426714268
} else {
1426814269
trx->rollback();
@@ -14278,6 +14279,7 @@ ha_innobase::rename_table(
1427814279
if (error == DB_SUCCESS) {
1427914280
log_write_up_to(trx->commit_lsn, true);
1428014281
}
14282+
trx->flush_log_later = false;
1428114283
trx->free();
1428214284

1428314285
if (error == DB_DUPLICATE_KEY) {

storage/innobase/trx/trx0trx.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ static void trx_flush_log_if_needed(lsn_t lsn, trx_t *trx)
12361236
if (log_sys.get_flushed_lsn() > lsn)
12371237
return;
12381238

1239-
const bool flush= trx->dict_operation ||
1239+
const bool flush=
12401240
(srv_file_flush_method != SRV_NOSYNC &&
12411241
(srv_flush_log_at_trx_commit & 1));
12421242

0 commit comments

Comments
 (0)