[MDEV-31713] Duplicate rows for unique index after upgrading from 10.6.11 to 10.6.14 Created: 2023-07-16  Updated: 2023-07-24  Resolved: 2023-07-24

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6.14
Fix Version/s: 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1

Type: Bug Priority: Blocker
Reporter: Olgun Adak Assignee: Marko Mäkelä
Resolution: Duplicate Votes: 1
Labels: regression-10.6
Environment:

FreeBSD 13.1-RELEASE-p8 - Mariadb 10.6.14


Issue Links:
Duplicate
duplicates MDEV-31120 Duplicate entry allowed into a UNIQUE... Closed

 Description   

After upgrading Mariadb from 10.6.11 to 10.6.14, we started to see multiple rows containing unique indices. When trying to insert rows with duplicate indices, we sometimes see "ERROR 1062 (23000): Duplicate entry" while sometimes it goes through. The table show duplicate rows with select statements. Recreating the index does not solve the problem.



 Comments   
Comment by Elena Stepanova [ 2023-07-16 ]

Can you provide a way to reproduce it?

Comment by Olgun Adak [ 2023-07-17 ]

We are looking to see if wee can replicate the issue on a newly built / empty database. We encountered the problem in our production database on multiple tables with unique indexes on two fields and we rolled back to 10.6.11.

Comment by Olgun Adak [ 2023-07-17 ]

We are not able to replicate the issue on a minimal new build where we install 10.6.14 and dump one table that had the issue with.
At the moment, we have binary logs from the production databases showing successful insert statements with duplicate unique indices as well as the slave logs showing the errors which allowed us to catch the issue. If this or any other thing from our logs would of any help, please let me know.

Comment by Daniel Black [ 2023-07-17 ]

Can you show the SHOW CREATE TABLE definition (even if table/column names are changed)?

Do you have a snapshot on which binary logs can be applied to create the duplicate?

What events are in the binary log indicative of the SQL statements? Are there types of SQL statements that occur very close to each other potentially allowing the duplicate?

What non-default configuration options are used my_print_defaults --mysqld?

So this is occurring on the master. Do occasionally duplicate find themselves in the replca tables or does the duplicate key error occur in replication predictably?

To explicitly use the secondary unique index can you try the query to validate the duplicate is in the secondary index.

SELECT dupfield, COUNT(*) cnt FROM tbl GROUP BY dupfiled HAVING cnt > 1;

Comment by Daniel Black [ 2023-07-17 ]

Thank you kindly.

Comment by Olgun Adak [ 2023-07-17 ]

One final note regarding #6: I have also tried to re-create the unique index and it failed and reported that there are duplicates. After removing the duplicates manually, I have recreated the index, but the duplicates continued to appear with the recreated index.

Comment by Elena Stepanova [ 2023-07-17 ]

Does CHECK TABLE .. EXTENDED show anything other than OK when duplicates occur? And are there any errors or warnings which seem to be relevant or at least unexpected in the server's error (not slave's log, but the one which has duplicates)?

Comment by Olgun Adak [ 2023-07-17 ]

I did not check that statement when the duplicates occurred and we have already downgraded.
Regarding the logs: I do not recall anything in master's error log when duplicates occurred, but we unfortunately rolled back the filesystem that contains the error log, so I am not able to double check that.

One thing that looked off after the upgrade was following statement at the top of the binlogs created with 10.6.14 and opened with 10.6.14's mariadb-binlog binary. This warning was appearing even after I restart the engine to move to new binary.

  1. Warning: this binlog is either in use or was not closed properly....

By the way, someone else seems to have experienced the same issue when moving from 10.3 to 10.6. She does not state the minor version, and she thinks she is solving it by fiddling with innodb parameters and does not file a bug report.

https://dba.stackexchange.com/questions/327421/mariadb-10-3-mariadb-10-6innodb-duplicate-entry-for-key-unique-ind

If you are completely stuck, we can try to clone our production database and repeat the upgrade to 10.6.14, however this will be a lengthy process and I also do not know exactly what to look for if I can get a problematic system up.

Comment by Elena Stepanova [ 2023-07-19 ]

I expect it will be tracked further in MDEV-31120, but I'll leave it to marko to decide.

You probably don't need a workaround if you rolled back anyway, but if you do, please try innodb_change_buffering=none, at least for now I suspect non-none-values to be causing the problem.

Comment by Olgun Adak [ 2023-07-20 ]

Thank you. We have already rolled back, and will upgrade to a release with a fix for this issue.

Comment by Marko Mäkelä [ 2023-07-24 ]

I think that this must duplicate MDEV-31120, which is a regression that was introduced in MariaDB Server 10.6.12.

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