Bug ID 1217688
Summary mariadb: a table is missing inserted entries from concurrent processes
Classification openSUSE
Product openSUSE Tumbleweed
Version Current
Hardware Other
URL https://jira.mariadb.org/browse/MDEV-32871
OS Other
Status NEW
Severity Normal
Priority P5 - None
Component Other
Assignee danilo.spinella@suse.com
Reporter jslaby@suse.com
QA Contact qa-bugs@suse.de
Target Milestone ---
Found By ---
Blocker ---

Created attachment 871082 [details]
db inserter

With mariadb: 11.0.2, 11.1.2 and 11.1.3 (from server:database):

From my c++ code, using connector-c, I do:

SET autocommit=0
CREATE TABLE IF NOT EXISTS sources(id INTEGER AUTO_INCREMENT PRIMARY KEY, src
VARCHAR(1024) NOT NULL UNIQUE)
INSERT IGNORE INTO sources(src) VALUES (?)
START TRANSACTION

And then a lot of:

INSERT IGNORE INTO sources(src) VALUES ('src-003431-00001')

src is composed of pid and values from 0 to 49. So they are all unique.
Finally, I do:

COMMIT

If I run 10 instances in parallel like:

for aa in {1..10} ; do ./db & done ; wait

I see:

select count(id), substr(src,5,6) as sss from sources group by sss;
+-----------+--------+
| count(id) | sss    |
+-----------+--------+
|        50 | 003430 |
|        50 | 003431 |
|        50 | 003432 |
|        40 | 003433 |
|        50 | 003434 |
|        50 | 003435 |
|        50 | 003436 |
|        50 | 003437 |
|        50 | 003438 |
|        50 | 003439 |
+-----------+--------+

I.e. Some of pids stored only last 40 values, numbers 0..9 are missing in the
table:

select src from sources where src like '%003433%' order by src ;

+------------------+
| src              |
+------------------+
| src-003433-00010 |
| src-003433-00011 |
| src-003433-00012 |
| src-003433-00013 |
| src-003433-00014 |
| src-003433-00015 |
| src-003433-00016 |
| src-003433-00017 |
| src-003433-00018 |
| src-003433-00019 |
| src-003433-00020 |
| src-003433-00021 |
| src-003433-00022 |
| src-003433-00023 |
| src-003433-00024 |
| src-003433-00025 |
| src-003433-00026 |
| src-003433-00027 |
| src-003433-00028 |
| src-003433-00029 |
| src-003433-00030 |
| src-003433-00031 |
| src-003433-00032 |
| src-003433-00033 |
| src-003433-00034 |
| src-003433-00035 |
| src-003433-00036 |
| src-003433-00037 |
| src-003433-00038 |
| src-003433-00039 |
| src-003433-00040 |
| src-003433-00041 |
| src-003433-00042 |
| src-003433-00043 |
| src-003433-00044 |
| src-003433-00045 |
| src-003433-00046 |
| src-003433-00047 |
| src-003433-00048 |
| src-003433-00049 |
+------------------+

Is this a bug in my program (attached) or the db? If I look into the general
log, I see the inserts which apparently did not get into the table:

grep src-003433 /tmp/glog

                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00000')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00000')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00000')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00000')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00000')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00001')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00002')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00003')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00004')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00005')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00006')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00007')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00008')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00009')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00010')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00010')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00011')
                    24 Execute  INSERT IGNORE INTO sources(src) VALUES
('src-003433-00012')

Note also the repeated inserts. They come from a deadlock, so I repeat the exec
in a loop (see the code).

Dockers with

    mariadb:latest (11.2.2)
    mariadb:11.1.3
    mariadb:11.1.2

all run FINE too.


You are receiving this mail because: