mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #32709: Assertion failed: trx_data->empty(), file log.cc
The assertion indicates that some data was left in the transaction cache when the server was shut down, which means that a previous statement did not commit or rollback correctly. What happened was that a bug in the rollback of a transactional table caused the transaction cache to be emptied, but not reset. The error can be triggered by having a failing UPDATE or INSERT, on a transactional table, causing an implicit rollback. Fixed by always flushing the pending event to reset the state properly.
This commit is contained in:
26
sql/log.cc
26
sql/log.cc
@ -1421,6 +1421,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
|
||||
If rolling back a statement in a transaction, we truncate the
|
||||
transaction cache to remove the statement.
|
||||
*/
|
||||
thd->binlog_remove_pending_rows_event(TRUE);
|
||||
if (all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)))
|
||||
trx_data->reset();
|
||||
else // ...statement
|
||||
@ -3769,6 +3770,31 @@ THD::binlog_set_pending_rows_event(Rows_log_event* ev)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove the pending rows event, discarding any outstanding rows.
|
||||
|
||||
If there is no pending rows event available, this is effectively a
|
||||
no-op.
|
||||
*/
|
||||
int
|
||||
MYSQL_BIN_LOG::remove_pending_rows_event(THD *thd)
|
||||
{
|
||||
DBUG_ENTER(__FUNCTION__);
|
||||
|
||||
binlog_trx_data *const trx_data=
|
||||
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
|
||||
|
||||
DBUG_ASSERT(trx_data);
|
||||
|
||||
if (Rows_log_event* pending= trx_data->pending())
|
||||
{
|
||||
delete pending;
|
||||
trx_data->set_pending(NULL);
|
||||
}
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/*
|
||||
Moves the last bunch of rows from the pending Rows event to the binlog
|
||||
(either cached binlog if transaction, or disk binlog). Sets a new pending
|
||||
|
Reference in New Issue
Block a user