Skip to content

fix: fixes SQLITE not respecting orderby + limit on update#161

Merged
GiovaniGuizzo merged 1 commit intomasterfrom
fix/concurrency
Feb 4, 2026
Merged

fix: fixes SQLITE not respecting orderby + limit on update#161
GiovaniGuizzo merged 1 commit intomasterfrom
fix/concurrency

Conversation

@GiovaniGuizzo
Copy link
Contributor

Checklist for Pull Requests

  • All tests pass (yarn test:all and yarn test:integration)
  • Code follows the style guide and passes lint checks
  • Documentation is updated (README, docs, etc)
  • Linked to corresponding issue, if applicable

Summary of Changes

Closes #159

Apparently, SQLite does not respect updates with order by and limit. For it do be able to do so, one must enable SQLITE_ENABLE_UPDATE_DELETE_LIMIT during compilation time. For what is worth, better-sqlite3 has this option enabled, but it doesn't work.

I have added a very important missing test case where we assert whether claimPendingJob claims only the quantity passed. It works on all dbs, except SQLite. I tried using both sqlite3 and better-sqlite3, none worked.

An alternative solution would be for us to compile our own version of SQLite, but I'd rather not.

This solution that I cam up with is not perfect, but it gets the job done. We first select the jobs to update, then update them in a second instruction. In a race condition, we might have a job being claimed by two different workers, but I kept the status = waiting clause in the query to avoid that race condition.

@GiovaniGuizzo GiovaniGuizzo merged commit 6a15dec into master Feb 4, 2026
6 checks passed
@GiovaniGuizzo GiovaniGuizzo deleted the fix/concurrency branch February 4, 2026 19:52
sidequest-release bot pushed a commit that referenced this pull request Feb 4, 2026
## [1.13.7](v1.13.6...v1.13.7) (2026-02-04)

### Bug Fixes

* fixes SQLITE not respecting orderby + limit on update ([#161](#161)) ([6a15dec](6a15dec))
sidequest-release bot pushed a commit that referenced this pull request Feb 4, 2026
## [1.13.7](v1.13.6...v1.13.7) (2026-02-04)

### Bug Fixes

* fixes SQLITE not respecting orderby + limit on update ([#161](#161)) ([6a15dec](6a15dec))
sidequest-release bot pushed a commit that referenced this pull request Feb 4, 2026
## [1.13.7](v1.13.6...v1.13.7) (2026-02-04)

### Bug Fixes

* fixes SQLITE not respecting orderby + limit on update ([#161](#161)) ([6a15dec](6a15dec))
sidequest-release bot pushed a commit that referenced this pull request Feb 4, 2026
## [1.13.7](v1.13.6...v1.13.7) (2026-02-04)

### Bug Fixes

* fixes SQLITE not respecting orderby + limit on update ([#161](#161)) ([6a15dec](6a15dec))
sidequest-release bot pushed a commit that referenced this pull request Feb 4, 2026
## [1.13.7](v1.13.6...v1.13.7) (2026-02-04)

### Bug Fixes

* fixes SQLITE not respecting orderby + limit on update ([#161](#161)) ([6a15dec](6a15dec))
sidequest-release bot pushed a commit that referenced this pull request Feb 4, 2026
## [1.13.7](v1.13.6...v1.13.7) (2026-02-04)

### Bug Fixes

* fixed CI/CD ([ce35ef7](ce35ef7))
* fixes SQLITE not respecting orderby + limit on update ([#161](#161)) ([6a15dec](6a15dec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timeout behavior - unexpected timing issues

2 participants