Commit6b4b14eeRecorded24 Oct 2026Repositoryfolio
Test status cache invalidation between writes in one transaction
Changed
test/test-status-cache.sgl | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)Diff
test/test-status-cache.sglmodified
@@ -2,7 +2,8 @@
2
;;; 3
;;; The note summaries and orphan names behind status are cached on the 4
;;; notes/ listing, SQLite's data_version (another connection's commit) and−5
;;; total_changes() (this connection's own writes). Every invalidation case+5
;;; total_changes() (this connection's own writes), plus its transaction count.+6
;;; Every invalidation case 7
;;; compares the cached answer with a FRESH index connection on the same 8
;;; database, which has no cache, so a stale hit fails here. 9
(import (sigil test)@@ -112,6 +113,27 @@
113
(assert-equal "a" (folio-note-name (car (dict-ref (folio-status store idx) recent-notes:)))) 114
(assert-matches-fresh store idx)))) 115
+116
;; The transaction counter changes only on entry and exit. Between two+117
;; reads inside it, only total_changes distinguishes this connection's writes.+118
(test "successive writes inside one transaction refresh the summaries"+119
(with-status-store+120
(lambda (root store idx server)+121
(with-index-transaction idx+122
(lambda ()+123
(assert-true (sqlite-run (folio-index-db idx)+124
"UPDATE notes_meta SET last_updated = ? WHERE name = ?"+125
"2098-06-01" "a"))+126
(assert-equal "a"+127
(folio-note-name+128
(car (dict-ref (folio-status store idx) recent-notes:))))+129
(assert-true (sqlite-run (folio-index-db idx)+130
"UPDATE notes_meta SET last_updated = ? WHERE name = ?"+131
"2099-06-01" "b"))+132
(assert-equal "b"+133
(folio-note-name+134
(car (dict-ref (folio-status store idx) recent-notes:))))))+135
(assert-matches-fresh store idx))))+136
137
;; A TEMP table shadows the main one for this connection only, and creating 138
;; or dropping it moves no part of the key, so a failure cached here would 139
;; stay until something unrelated changed.