Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions crates/database/db/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,15 @@ impl<T: ReadConnectionProvider + Sync + ?Sized> DatabaseReadOperations for T {
.one(self.get_connection())
.await?
{
// Yield n messages starting from the found queue index + 1.
// Yield n messages starting from the found queue index + 1. Only return
// messages that have not been skipped (skipped = false) to handle the edge
// case where the last message in a batch is skipped.
let condition = Condition::all()
// We add 1 to the queue index to constrain across block boundaries
.add(models::l1_message::Column::QueueIndex.gte(record.queue_index + 1))
.add(models::l1_message::Column::Skipped.eq(false));
Ok(models::l1_message::Entity::find()
.filter(
// We add 1 to the queue index to constrain across block boundaries
models::l1_message::Column::QueueIndex.gte(record.queue_index + 1),
)
.filter(condition)
.order_by_asc(models::l1_message::Column::QueueIndex)
.limit(Some(n as u64))
.all(self.get_connection())
Expand All @@ -871,6 +874,7 @@ impl<T: ReadConnectionProvider + Sync + ?Sized> DatabaseReadOperations for T {
// index starting from the beginning.
else {
Ok(models::l1_message::Entity::find()
.filter(models::l1_message::Column::Skipped.eq(false))
.order_by_asc(models::l1_message::Column::QueueIndex)
.limit(Some(n as u64))
.all(self.get_connection())
Expand Down
Loading