[PR #5562] [CLOSED] fix(sqlite): eliminate redundant table scan and add WAL checkpoint timeout #6961

Closed
opened 2026-11-01 21:44:21 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5562
Author: @ZG0D-FF
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/sqlite-wal-concurrency-truncation


📝 Commits (2)

  • 232402c fix(sqlite): eliminate redundant table scan and add WAL checkpoint timeout
  • 35d3251 fix(sqlite): retain SELECT 1 truncation probe to protect virtual generated columns

📊 Changes

1 file changed (+1 additions, -2 deletions)

View changed files

📝 src/sqlite/SqliteDatabaseInspection.ts (+1 -2)

📄 Description

Summary

Fixes #5284, Fixes #5286, Ref #5520.
Eliminates SQLITE_BUSY errors during active WAL writer checkpoints and avoids table re-scans when evaluating row truncation.

Problem and expected behavior

  1. DatabaseSync was instantiated with timeout: 0, causing immediate failures if opened during WAL autocheckpoints.
  2. Row truncation executed a third SELECT 1 ... OFFSET ? query, scanning the table an extra time.
  3. Iterating limit + 1 on the projection statement projected expensive hex(CAST(... AS BLOB)) values for rows that were immediately discarded.

Change and scope

  1. Set timeout: 2000 on DatabaseSync instantiation.
  2. Run lightweight lengths.iterate(limit + 1) to determine truncation in-stream, then query only the exact needed rows for projection.

Contract and boundary impact

  • Semantic owner: sqlite
  • Contribution scope fit: bugfix / perf
  • CLI and MCP/tool-catalog contract: none
  • Platform compatibility: Node 22.x, 24.x, 26.x DatabaseSync

Author readiness

Human owner: @ZG0D-FF

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5562 **Author:** [@ZG0D-FF](https://github.com/ZG0D-FF) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/sqlite-wal-concurrency-truncation` --- ### 📝 Commits (2) - [`232402c`](https://github.com/morluto/rea/commit/232402cb530af4c84074c2e62a9eba679695b645) fix(sqlite): eliminate redundant table scan and add WAL checkpoint timeout - [`35d3251`](https://github.com/morluto/rea/commit/35d3251fc99ce70bc7ae7bab385efefd6a5f3696) fix(sqlite): retain SELECT 1 truncation probe to protect virtual generated columns ### 📊 Changes **1 file changed** (+1 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/sqlite/SqliteDatabaseInspection.ts` (+1 -2) </details> ### 📄 Description ## Summary Fixes #5284, Fixes #5286, Ref #5520. Eliminates SQLITE_BUSY errors during active WAL writer checkpoints and avoids table re-scans when evaluating row truncation. ## Problem and expected behavior 1. DatabaseSync was instantiated with timeout: 0, causing immediate failures if opened during WAL autocheckpoints. 2. Row truncation executed a third SELECT 1 ... OFFSET ? query, scanning the table an extra time. 3. Iterating limit + 1 on the projection statement projected expensive hex(CAST(... AS BLOB)) values for rows that were immediately discarded. ## Change and scope 1. Set timeout: 2000 on DatabaseSync instantiation. 2. Run lightweight lengths.iterate(limit + 1) to determine truncation in-stream, then query only the exact needed rows for projection. ## Contract and boundary impact - Semantic owner: sqlite - Contribution scope fit: bugfix / perf - CLI and MCP/tool-catalog contract: none - Platform compatibility: Node 22.x, 24.x, 26.x DatabaseSync ## Author readiness Human owner: @ZG0D-FF - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:44:21 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6961
No description provided.