Skip to content

Commit da740da

Browse files
poorbarcodelhotari
andcommitted
[improve][ml] Offload ledgers without check ledger length (#24344)
Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> (cherry picked from commit 3ccea6a)
1 parent 323e2ff commit da740da

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

tiered-storage/file-system/src/main/java/org/apache/bookkeeper/mledger/offload/filesystem/impl/FileSystemManagedLedgerOffloader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,16 @@ private LedgerReader(ReadHandle readHandle,
194194

195195
@Override
196196
public void run() {
197-
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
197+
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
198198
promise.completeExceptionally(
199199
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
200200
return;
201201
}
202+
if (readHandle.getLength() <= 0) {
203+
log.warn("Ledger [{}] has zero length, but it contains {} entries. "
204+
+ " Attempting to offload ledger since it contains entries.", readHandle.getId(),
205+
readHandle.getLastAddConfirmed() + 1);
206+
}
202207
long ledgerId = readHandle.getId();
203208
final String managedLedgerName = extraMetadata.get(MANAGED_LEDGER_NAME);
204209
String storagePath = getStoragePath(storageBasePath, managedLedgerName);

tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,16 @@ public CompletableFuture<Void> offload(ReadHandle readHandle,
200200
final BlobStore writeBlobStore = getBlobStore(config.getBlobStoreLocation());
201201
log.info("offload {} uuid {} extraMetadata {} to {} {}", readHandle.getId(), uuid, extraMetadata,
202202
config.getBlobStoreLocation(), writeBlobStore);
203-
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
203+
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
204204
promise.completeExceptionally(
205205
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
206206
return;
207207
}
208+
if (readHandle.getLength() <= 0) {
209+
log.warn("[{}] Ledger [{}] has zero length, but it contains {} entries."
210+
+ " Attempting to offload ledger since it contains entries.", topicName, readHandle.getId(),
211+
readHandle.getLastAddConfirmed() + 1);
212+
}
208213
OffloadIndexBlockBuilder indexBuilder = OffloadIndexBlockBuilder.create()
209214
.withLedgerMetadata(readHandle.getLedgerMetadata())
210215
.withDataBlockHeaderLength(BlockAwareSegmentInputStreamImpl.getHeaderSize());

0 commit comments

Comments
 (0)