fix(database): load the closed upper bound of the db_get_record window

db_get_record accepts a record up to half the window after the target,
but loaded only [start, end) from storage. A stored record on the upper
bound, or in the last second of a window with a fractional half width,
was not found when that part of the store was not in memory yet, and
the loaded range then stayed marked as covered. db_get_record now loads
the last second of the window as well; key_to_value relies on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
Christin
2026-11-28 08:08:37 +01:00
committed by Bobby Noelte
co-authored by Claude Opus 5.5
parent c1340ff56c
commit c563043af2
2 changed files with 35 additions and 1 deletions
+7 -1
View File
@@ -1416,7 +1416,13 @@ class DatabaseRecordProtocolMixin(
# load the relevant range
# in case of unbounded escalates to FULL
search_start, search_end = self._search_window(target_timestamp, time_window)
await self._db_ensure_loaded(search_start, search_end, center_timestamp=target_timestamp)
# The window is closed: also load the records of its last second.
load_end = (
self._db_timestamp_after(search_end)
if isinstance(search_end, DatabaseTimestamp)
else search_end
)
await self._db_ensure_loaded(search_start, load_end, center_timestamp=target_timestamp)
# Exact match first (works for all three cases once loaded)
record = self._db_record_index.get(target_timestamp, None)