Skip to content

Duplicate entry error when inserting to multiple sysbench tables #1

@PrzemekMalkowski

Description

@PrzemekMalkowski

I prepared 4 empty standard sysbench tables, i.e.:

mysql [localhost:8406] {msandbox} (db1) > show create table db1.sbtest1\G
*************************** 1. row ***************************
       Table: sbtest1
Create Table: CREATE TABLE `sbtest1` (
  `id` int NOT NULL AUTO_INCREMENT,
  `k` int NOT NULL DEFAULT '0',
  `c` char(120) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `pad` char(60) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `k_1` (`k`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
1 row in set (0.01 sec)

The tool fails when I invoke it with a query joining all four:

$ ./random-data-load run --engine=mysql --user=root --password='msandbox' --host="127.0.0.1" --port=8406 --rows=100000 --database=db2 --query="SELECT t1.c, t2.c, t3.c, t4.c FROM sbtest1 t1 LEFT JOIN sbtest2 t2 ON t1.id = t2.id LEFT JOIN sbtest3 t3 ON t1.id = t3.id LEFT JOIN sbtest4 t4 ON t1.id = t4.id WHERE t1.id = 49877"
Writing sbtest4 (100000/100000) rows...
Writing sbtest3 (100000/100000) rows...
Writing sbtest1 (100000/100000) rows...
random-data-load: error: failed to insert on db2.sbtest2: failed after 5 retries: Error 1062 (23000): Duplicate entry '6696' for key 'sbtest2.PRIMARY'

Inserting only to that table works fine:

$ ./random-data-load run --engine=mysql --user=root --password='msandbox' --host="127.0.0.1" --port=8406 --rows=100000 --database=db2 --table=sbtest2
Writing sbtest2 (100000/100000) rows...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions