MerginMaps / MerginMaps/geodiff
GEODIFF_rebase assigns negative FIDs when sqlite_sequence.seq exceeds INT32_MAX
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 183
- Forks
- 21
- Avg merge
- 9d 11h
- Merged PRs (30d)
- 2
Description
When two devices concurrently add features to a GeoPackage layer and one needs to rebase against the other's changes, the rebased device's new features receive negative FIDs. The root cause is a silent narrowing cast from int64_t to int (32-bit) in the rebase code, which corrupts FID values whenever sqlite_sequence.seq exceeds INT32_MAX (2,147,483,647).
This was observed in a real project where sqlite_sequence.seq had grown to 77,194,629,200 — well beyond INT32_MAX. The table itself contained only 244 rows (FIDs 1–244), but the high-water mark in sqlite_sequence persisted from a prior operation. With 8 devices collecting data simultaneously, every device except the first to sync received negative FIDs for all newly added features. The pattern was fully deterministic: first sync → positive FIDs, all subsequent syncs → negative FIDs.
Note that sqlite_sequence is intentionally excluded from geodiff changesets (https://github.com/MerginMaps/geodiff/blob/master/geodiff/src/drivers/sqlitedriver.cpp#L232), which means a corrupted seq value is not visible to geodiff and cannot be corrected via normal (diff) sync.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in geodiff/src/drivers/sqlitedriver.cpp, including the sqlite_sequence handling around line 232, and trace the rebase path that assigns new feature IDs. Reproduce a rebase with sqlite_sequence.seq above INT32_MAX and verify that newly added features receive positive, non-corrupted FIDs without changing the intended exclusion from changesets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100