Skip to content

Commit 926422b

Browse files
ldanilekConvex, Inc.
authored andcommitted
ensure Interval advances (#23440)
return errors if we are fetching a page from an index range and the remaining Interval to query does not shrink. Do this at the lowest levels where we compute the remaining_intervals -- once where we merge it with pending writes, and once where we truncate results based on length and bytes size. and also do this at the highest level where we absolutely require the interval to be advancing -- in the Query loop. GitOrigin-RevId: 8e74577b5a53314c066a3ebaae5f2e9e54a49bdc
1 parent 4b0e312 commit 926422b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

crates/database/src/query/index_range.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl<T: QueryType> IndexRange<T> {
213213
self.version.clone(),
214214
)
215215
.await?;
216+
anyhow::ensure!(self.unfetched_interval != new_unfetched_interval);
216217
self.unfetched_interval = new_unfetched_interval;
217218
self.page_count += 1;
218219
self.rows_read += page.len();

crates/database/src/transaction_index.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ impl TransactionIndex {
237237
(None, None) => break,
238238
}
239239
}
240+
if remaining_interval == range_request.interval {
241+
Err(anyhow::anyhow!(
242+
"query for {remaining_interval:?} did not shrink"
243+
))?;
244+
}
240245
(range_results, remaining_interval)
241246
};
242247
assert!(results.insert(batch_key, item_result).is_none());
@@ -382,6 +387,11 @@ impl TransactionIndex {
382387
indexed_fields.clone(),
383388
interval_read,
384389
)?;
390+
if interval_unread == interval {
391+
Err(anyhow::anyhow!(
392+
"query for {interval_unread:?} did not shrink"
393+
))?;
394+
}
385395
(out, interval_unread)
386396
};
387397
assert!(results.insert(batch_key, result).is_none());

0 commit comments

Comments
 (0)