[MDEV-30163] Unexpected ERROR 1442 (Can't update table X in stored function/trigger because it is already used by statement which invoked this stored function/trigger) in very particular circumstances Created: 2022-12-05 Updated: 2023-11-28 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.5.2, 10.5.18, 10.6.11, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.5, 10.6 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Aaron Sokoloski | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux (docker image) |
||
| Attachments: |
|
| Description |
|
I stumbled on to this when testing things out prior to upgrading our server. Starting at server version 10.5.2, and seemingly going until version 10.6.11 at least (haven't tested newer versions), this minimal script seems to trigger this error. 10.5.1 and earlier seems not to show it. (We've been using the official docker image to test different versions) Please note the inline comments about how modifying the script can make the issue disappear – it seems to only happen in very particular circumstances, with both insert and update triggers present that insert into a table, and a view that references that same table. Code that shows the issue (also attached to this ticket)
The error is: From my point of view, this seems like a bug in newer versions. That is, unless I'm misunderstanding things and an error should always have occurred in this situation, though the message doesn't really make much sense to me or seem relevant to what the script is doing. And it's very strange to me that the presence or absence of a view referencing the table that the trigger inserts into makes a difference, as well as the presence or absence of a trigger that isn't even being executed. This is something I can work around by fiddling with the lock statement as described in the script comments, it was just rather confusing and I wanted to make sure that people were aware of it, and maybe help out some others who have run into the same issue. Thanks to everyone who works on MariaDB! |
| Comments |
| Comment by Alice Sherepa [ 2022-12-06 ] |
|
Thanks for the report! I repeated as described on 10.5-10.11 |