-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-38993 Assertion `trx->undo_no == 1' fails upon ALTER IGNORE #4746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Thirunarayanan
wants to merge
1
commit into
10.11
Choose a base branch
from
MDEV-38993
base: 10.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1807,6 +1807,30 @@ static bool trx_has_lock_x(const trx_t &trx, dict_table_t& table) | |
| return false; | ||
| } | ||
|
|
||
| /** For ALTER TABLE...IGNORE ALGORITHM=COPY, rewind the undo log | ||
| to maintain only the latest insert undo record. This allows easy | ||
| rollback of the last inserted row on duplicate key errors. | ||
| @param table table being altered | ||
| @param trx transaction | ||
| @param undo insert undo log | ||
| @param undo_block undo log page | ||
| @param mtr mini-transaction | ||
| @param m mod_tables entry to reinitialize */ | ||
| static ATTRIBUTE_COLD ATTRIBUTE_NOINLINE | ||
| void trx_undo_rewrite_ignore(dict_table_t *table, trx_t *trx, trx_undo_t *undo, | ||
| buf_block_t *undo_block, mtr_t *mtr, | ||
| std::pair<trx_mod_tables_t::iterator, bool> &m) | ||
| { | ||
| ut_ad(trx->undo_no == 1); | ||
| undo->top_offset= undo->old_offset; | ||
| undo->top_undo_no= 0; | ||
| trx->undo_no= 0; | ||
| trx->mod_tables.clear(); | ||
| m= trx->mod_tables.emplace(table, 0); | ||
| mtr->write<2>(*undo_block, undo_block->page.frame + TRX_UNDO_PAGE_HDR + | ||
| TRX_UNDO_PAGE_FREE, undo->old_offset); | ||
| } | ||
|
|
||
| /***********************************************************************//** | ||
| Writes information to an undo log about an insert, update, or a delete marking | ||
| of a clustered index record. This information is used in a rollback of the | ||
|
|
@@ -1912,32 +1936,18 @@ trx_undo_report_row_operation( | |
| ut_ad(!trx->read_only); | ||
| ut_ad(trx->id); | ||
| pundo = &trx->rsegs.m_redo.undo; | ||
| const bool empty{!*pundo}; | ||
| const bool clear_ignore{*pundo && trx->undo_no && | ||
| (*pundo)->old_offset <= | ||
| (*pundo)->top_offset && | ||
| index->table->skip_alter_undo == | ||
| dict_table_t::IGNORE_UNDO}; | ||
|
Comment on lines
+1939
to
+1943
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation is a bit weird here. I would format it as follows to conform to the original InnoDB formatting style that is being used in this function: const bool clear_ignore = *pundo && trx->undo_no
&& (*pundo)->old_offset <= (*pundo)->top_offset
&& index->table->skip_alter_undo
== dict_table_t::IGNORE_UNDO; |
||
| rseg = trx->rsegs.m_redo.rseg; | ||
| undo_block = trx_undo_assign_low<false>(trx, rseg, pundo, | ||
| &mtr, &err); | ||
| /* For ALTER IGNORE, implement undo log rewriting | ||
| to maintain only the latest insert undo record. | ||
| This allows easy rollback of the last inserted row | ||
| on duplicate key errors. Before writing a new undo | ||
| record, rewind the undo log to the previous record | ||
| position, effectively discarding all intermediate | ||
| undo records and keeping only the most recent one. */ | ||
| if (!empty && (*pundo)->old_offset <= (*pundo)->top_offset && | ||
| index->table->skip_alter_undo == | ||
| dict_table_t::IGNORE_UNDO) { | ||
|
|
||
| if (clear_ignore) { | ||
| ut_ad(!rec); | ||
| ut_ad(trx->undo_no == 1); | ||
| (*pundo)->top_offset = (*pundo)->old_offset; | ||
| (*pundo)->top_undo_no = 0; | ||
| trx->undo_no = 0; | ||
| trx->mod_tables.clear(); | ||
| m = trx->mod_tables.emplace(index->table, 0); | ||
| mtr.write<2>( | ||
| *undo_block, | ||
| undo_block->page.frame + TRX_UNDO_PAGE_HDR + | ||
| TRX_UNDO_PAGE_FREE, (*pundo)->old_offset); | ||
| trx_undo_rewrite_ignore(index->table, trx, *pundo, | ||
| undo_block, &mtr, m); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters will not fit in the 6 registers that are available in the commonly used AMD64 calling conventions. I assume that this is the limiting factor on our common target platforms. On ARMv8 there seem to be 8 registers for passing parameters.
We can freely choose the order of the function body. I would make
mtr, undo_blockthe first parameters so that no registers have to be shuffled for the first call, like this:This will also enable a nice tail call optimization for the return value, which the caller would assign to its local variable
m.