Skip to content
Open
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
12 changes: 9 additions & 3 deletions internal/impl/aws/dynamodb/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ func (st *shardAckTracker) advanceFrontier(frontier string) {
}
}

// hasUnpersistedFrontier reports whether the shard has a contiguous acked
// sequence frontier that has not yet been persisted.
func (st *shardAckTracker) hasUnpersistedFrontier() bool {
return st.frontier != "" && st.frontier != st.persisted
}

// AckBatch marks a tracked batch as acknowledged, advances the shard's
// contiguous frontier, and persists a checkpoint once enough messages have
// been acked since the last persisted position. Settlement goes through the
Expand Down Expand Up @@ -475,7 +481,7 @@ func (b *RecordBatcher) maybePersist(ctx context.Context, cp checkpointer, st *s

for {
b.mu.Lock()
due := st.pending >= cp.CheckpointLimit() && st.frontier != "" && st.frontier != st.persisted
due := st.pending >= cp.CheckpointLimit() && st.hasUnpersistedFrontier()
persistSeq := st.frontier
persistTime := st.frontierTime
pendingAtCompute := st.pending
Expand Down Expand Up @@ -522,7 +528,7 @@ func (b *RecordBatcher) PendingCheckpoints() map[string]CheckpointValue {

checkpoints := make(map[string]CheckpointValue, len(b.shards))
for shardID, st := range b.shards {
if st.frontier != "" && st.frontier != st.persisted {
if st.hasUnpersistedFrontier() {
checkpoints[shardID] = CheckpointValue{
SequenceNumber: st.frontier,
ApproxCreationTime: st.frontierTime,
Expand Down Expand Up @@ -631,7 +637,7 @@ func (b *RecordBatcher) LastCheckpointsCount() int {
defer b.mu.Unlock()
n := 0
for _, st := range b.shards {
if st.frontier != "" && st.frontier != st.persisted {
if st.hasUnpersistedFrontier() {
n++
}
}
Expand Down