Skip to content

Commit 3ccea6a

Browse files
poorbarcodelhotari
andauthored
[improve][ml] Offload ledgers without check ledger length (#24344)
Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com>
1 parent 667780c commit 3ccea6a

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
@@ -204,11 +204,16 @@ public CompletableFuture<Void> offload(ReadHandle readHandle,
204204
final BlobStore writeBlobStore = getBlobStore(config.getBlobStoreLocation());
205205
log.info("offload {} uuid {} extraMetadata {} to {} {}", readHandle.getId(), uuid, extraMetadata,
206206
config.getBlobStoreLocation(), writeBlobStore);
207-
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
207+
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
208208
promise.completeExceptionally(
209209
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
210210
return;
211211
}
212+
if (readHandle.getLength() <= 0) {
213+
log.warn("[{}] Ledger [{}] has zero length, but it contains {} entries."
214+
+ " Attempting to offload ledger since it contains entries.", topicName, readHandle.getId(),
215+
readHandle.getLastAddConfirmed() + 1);
216+
}
212217
OffloadIndexBlockBuilder indexBuilder = OffloadIndexBlockBuilder.create()
213218
.withLedgerMetadata(readHandle.getLedgerMetadata())
214219
.withDataBlockHeaderLength(BlockAwareSegmentInputStreamImpl.getHeaderSize());

0 commit comments

Comments
 (0)