Skip to content

Commit 8feefbf

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

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
@@ -192,11 +192,16 @@ private LedgerReader(ReadHandle readHandle,
192192

193193
@Override
194194
public void run() {
195-
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
195+
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
196196
promise.completeExceptionally(
197197
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
198198
return;
199199
}
200+
if (readHandle.getLength() <= 0) {
201+
log.warn("Ledger [{}] has zero length, but it contains {} entries. "
202+
+ " Attempting to offload ledger since it contains entries.", readHandle.getId(),
203+
readHandle.getLastAddConfirmed() + 1);
204+
}
200205
long ledgerId = readHandle.getId();
201206
final String managedLedgerName = extraMetadata.get(MANAGED_LEDGER_NAME);
202207
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
@@ -195,11 +195,16 @@ public CompletableFuture<Void> offload(ReadHandle readHandle,
195195
final BlobStore writeBlobStore = getBlobStore(config.getBlobStoreLocation());
196196
log.info("offload {} uuid {} extraMetadata {} to {} {}", readHandle.getId(), uuid, extraMetadata,
197197
config.getBlobStoreLocation(), writeBlobStore);
198-
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
198+
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
199199
promise.completeExceptionally(
200200
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
201201
return;
202202
}
203+
if (readHandle.getLength() <= 0) {
204+
log.warn("[{}] Ledger [{}] has zero length, but it contains {} entries."
205+
+ " Attempting to offload ledger since it contains entries.", topicName, readHandle.getId(),
206+
readHandle.getLastAddConfirmed() + 1);
207+
}
203208
OffloadIndexBlockBuilder indexBuilder = OffloadIndexBlockBuilder.create()
204209
.withLedgerMetadata(readHandle.getLedgerMetadata())
205210
.withDataBlockHeaderLength(BlockAwareSegmentInputStreamImpl.getHeaderSize());

0 commit comments

Comments
 (0)