[MDEV-21442] Changes to temporary tables are no longer logged Created: 2020-01-08  Updated: 2023-12-05

Status: Stalled
Project: MariaDB Server
Component/s: Documentation, Replication
Affects Version/s: 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Michaël de groot Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-17863 DROP TEMPORARY TABLE creates a transa... Closed

 Description   

According to the documentation (https://mariadb.com/kb/en/read-only-slaves/) changes to TEMPORARY TABLEs are no longer logged in the binary log:
CREATE, DROP, ALTER, INSERT and DELETE of temporary tables are not logged to binary log, even in statement or mixed mode. With earlier MariaDB versions, one can avoid the problem with temporary tables by using binlog_format=ROW in which cases temporary tables are never logged.

I don't think this is correct, imagin this:

CREATE TEMPORARY TABLE encrypt_the_password AS select id, username, MD5(password) FROM user;
INSERT INTO user_with_encryped_password SELECT * FROM encrypt_the_password;

The `user_with_encryped_password` table is a real table, and it cannot be filled if the temporary table does not exist in that session. Using SBR or MIXED replication, that is.

Is the documentation incorrect or is this a bug in the server?



 Comments   
Comment by Sergei Golubchik [ 2020-02-11 ]

Did you verify that this doesn't work in SBR or MIXED but used to work before?

Comment by Michaël de groot [ 2020-02-11 ]

I did not, I do recollect using similar statements to this in systems with SBR.

It might as well that it still works and that the documentation is incorrect.

Comment by Elena Stepanova [ 2020-03-17 ]

Documentation certainly doesn't match the current implementation. Possibly it happened because there were several commits related to this, all without a JIRA item, and some were apparently reverting others, intentionally or not.

However, I'm not quite sure that the current implementation itself is correct and should be documented as is.

I suggest that at least Elkin reviews the current situation (once again) before passing it over to documentation, and maybe helps to summarize it for documentation purposes. Also, when time permits, I recommend alice to do some testing with temporary tables / different binlog formats / read_only=0|1.

The combination of temporary tables and binary logging has always been fragile, read_only makes it even more so. The scenario from the description doesn't fail right away, but it doesn't seem very convincing. At the first glance, the behavior in regard to (not-)logging temporary tables is different depending on how the table was created (CREATE vs CREATE .. SELECT). Also, it seems that in some cases actions on temporary tables make binary logging switch to row format even in SBR mode. I hope we only have very few users of true statement mode (as opposed to mixed), but those who do use it probably do it because they don't want any row events in their binary log.

Comment by Kfir Itzhak [ 2021-01-24 ]

This looks like a bug i am experiencing. Worked fine in 5.5, broke after upgrading to 10.3
https://jira.mariadb.org/browse/MDEV-24667

Comment by Elena Stepanova [ 2021-01-24 ]

This is not the same. The claim in this report is related to changes for read-only slaves introduced in 10.3; and while it's difficult dismiss given the variety of use cases and fragility of the area, it remains hypothetical until proven otherwise.

Your case in MDEV-24667 is very specific and very real, and it is unrelated to 10.3 changes, it's caused by much earlier 10.0 changes.

Comment by Barry [ 2022-07-19 ]

Hi @Elena Stepanova - I'm curious about this issue which you mention:

> At the first glance, the behavior in regard to (not-)logging temporary tables is different depending on how the table was created (CREATE vs CREATE .. SELECT).

Is this intentional behavior? I have verified that in 10.3 --> 10.5 if binlog_format is MIXED or STATEMENT AND if the server is in read_only mode, the following query will NOT result in an entry in the binlog:

CREATE TEMPORARY TABLE t1_temp (id INT);

Whereas the following query WILL create 2 entries (one for the create and one for the drop when the session ends) (table t1 of course has to exist)

CREATE TEMPORARY TABLE t1_temp LIKE t1;

Comment by Julien Fritsch [ 2023-12-05 ]

Automated message:
----------------------------
Since this issue has not been updated since 6 weeks, it's time to move it back to Stalled.

Comment by JiraAutomate [ 2023-12-05 ]

Automated message:
----------------------------
Since this issue has not been updated since 6 weeks, it's time to move it back to Stalled.

Generated at Thu Feb 08 09:07:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.