AnswerDotAI / AnswerDotAI/sqlite-minutils

With manual transactions, race conditions on `last_insert_rowid()` need to be accounted for

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
17
Forks
9
PR merge metrics
No merged PRs in 30d

Description

## Race condition scenario with new configuration:

```python
# pseudocode

# We insert the record here!
db.insert(...)

# ! Record adding in different process increments the ROWID by another one

# Let's see the last PK, but now it's been incremented 0-to-many times
print(db.last_pk)
```

## Probably not a fix

```python
db.begin()
db.insert(...)
print(db.get_last_rowid()) # Not necessarily the record
db.commit()
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the db.insert, db.last_pk, and db.get_last_rowid entry points described in the issue, then review how manual transactions interact with concurrent processes. Reproduce the interleaving shown in the pseudocode and establish the expected primary-key behavior before deciding what a complete fix or test should cover.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.