Skip to content

Insert error: PRIMARY KEY must be unique  #1

@ech-o-o

Description

@ech-o-o

I want to run your code for learning. I notice your code is coupled with mobibench. The only change I made is to change "extern int num_threads;" into "int num_threads=1;" because I am running with only one thread.
The test.c I run does the following things:

  1. Open a new database.
  2. CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY not null, name TEXT not null, postcode INTEGER not null, salary INTEGER not null;
  3. Insert pre-generated data into the table. The data follows the following form: %10d, %5s, %5s, %d when generating. The data has less byte width but more fields than your mobibench. The data is generated by faker library in python by:
from faker import Faker
faker = Faker()
trace_num = 20000
#  The directory of trace file
trace_file = "./trace/" + str(trace_num) + "-test.trace"
with open(trace_file, "w+") as f:
    ids = set()
    while len(ids) < trace_num :
        id = faker.pyint(0, 10**10)
        name = faker.pystr(8, 8)
        postcode = faker.postcode()
        salary = faker.pyint(0, 10000)
        if id not in ids:
            ids.add(id)
            content = "%10d, %5s, %5s, %d\n"%(id ,name ,postcode, salary)
            f.write( content )

And it may output an error after about 30k insertion: Insert error: PRIMARY KEY must be unique.
When I do the testing if the data we insert can be read, the key which output error is not able to be read. BTW, if I close the database and reopen it, it may warn database is corrupyted.

Running your mobibench, I find after a specific volumn, more volumn inserted, higher throughput.

All the testing is under the environment:
Linux 6.5.0-15-generic
Ubuntu 22.04.1
gcc 9.5.0

Would you please take a look on it? If there exist a bug, would you please fix it? THX!

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