Skip to content

Commit a86ce4a

Browse files
committed
Fix totalSnapshotLength
1 parent c8f77d9 commit a86ce4a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ private void afterCreateImmutableBucket(Pair<ImmutableBucket, DelayedIndex> immu
342342
CompletableFuture<Long> future = createFuture.handle((bucketId, ex) -> {
343343
if (ex == null) {
344344
immutableBucket.setSnapshotSegments(null);
345-
immutableBucket.asyncUpdateSnapshotLength();
345+
immutableBucket.asyncUpdateSnapshotLength()
346+
.thenRun(() -> immutableBuckets.recomputeCounters());
346347
log.info()
347348
.attr("bucketKey", immutableBucket.bucketKey())
348349
.log("Create bucket snapshot finish, bucketKey");

pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,20 @@ private CompletableFuture<List<DelayedIndex>> asyncLoadNextBucketSnapshotEntry(b
130130
.log("Failed to get bucket snapshot segment");
131131
}
132132
}), BucketSnapshotPersistenceException.class, MaxRetryTimes)
133-
.thenApply(bucketSnapshotSegments -> {
133+
.thenCompose(bucketSnapshotSegments -> {
134134
if (CollectionUtils.isEmpty(bucketSnapshotSegments)) {
135-
return Collections.emptyList();
135+
return CompletableFuture.completedFuture(Collections.emptyList());
136136
}
137137

138138
SnapshotSegment snapshotSegment =
139139
bucketSnapshotSegments.get(0);
140140
List<DelayedIndex> indexList = snapshotSegment.getIndexesList();
141141
this.setCurrentSegmentEntryId(nextSegmentEntryId);
142142
if (isRecover) {
143-
this.asyncUpdateSnapshotLength();
143+
return this.asyncUpdateSnapshotLength()
144+
.thenApply(__ -> indexList);
144145
}
145-
return indexList;
146+
return CompletableFuture.completedFuture(indexList);
146147
});
147148
});
148149
}

0 commit comments

Comments
 (0)