[MDEV-28612] Server crash caused by concurrent inserts into table with sequence default Created: 2022-05-18  Updated: 2023-08-05

Status: Open
Project: MariaDB Server
Component/s: Data Manipulation - Insert, Sequences
Affects Version/s: 10.4.24
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Jon Heffley Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: HTML File MDEV-28612_error_log     File my.cnf.tar    
Issue Links:
Relates
relates to MDEV-22785 Crash with prepared statements and NE... Closed
relates to MDEV-31854 Server crash, ASAN errors, assertion ... Open

 Description   

Our company has experienced server crashes due to this reproducible bug. Follow the steps below to reproduce it.

```
create sequence foo;
create table bar (x int primary key default (next value for foo), y int);
```

On two different sessions, run the following. For me, this caused a DB server crash within about two minutes:

```
while 1=1 do
insert into bar ( y )
select <<<something>>> from <<<something>>>;
rollback;
end while;
```

This version of the insert does not appear to cause the server crash:
```
while 1=1 do
insert into bar (x,y)
select next value for foo, <<<something>>> from <<<something>>>;
rollback;
end while;
```

The core dump for this crash indicated this as the failure:
Item_func_nextval::val_int (this=0x7f1e78cca8a8) at /usr/src/debug/MariaDB-10.4.24/src_0/sql/item_func.cc:6877



 Comments   
Comment by Alice Sherepa [ 2022-05-20 ]

Could you please provide the error log and my.cnf?

Comment by Jon Heffley [ 2022-05-20 ]

Attaching my.cnf.tar for the requested my.cnf file; and attaching MDEV-28612_error_log for the requested error log.

Comment by Jon Heffley [ 2022-05-20 ]

I don't seem to be able to change the status on this ticket; I hope that supplying this information is sufficient response.

Comment by Alice Sherepa [ 2022-08-03 ]

I can't repeat it, could you please provide a script to demonstrate the issue?

Comment by Jon Heffley [ 2022-08-03 ]

I was just now able to repeat it by running the following. It took about 30 seconds before my (development) DB server crashed.

Open two different sessions to the same server and database.

– in Session #1
create sequence foo;
create table bar (x int primary key default (next value for foo), y int);

– in both Session #1 and Session #2 run this concurrently:
while 1=1 do
insert into bar ( y )
select 1;
rollback;
end while;

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