Skip to content

Commit 06bb51d

Browse files
Add debug logging for segment boundary tracking and retry offsets
Added verbose logging to track: - Segment completion with byte offsets in StructuredMessageDecoder - Retry offset calculation in DecoderState - Retry range in BlobAsyncClientBase for structured messages This helps diagnose smart retry behavior and verify segment boundary alignment. Co-authored-by: gunjansingh-msft <[email protected]>
1 parent 4c1a3fa commit 06bb51d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,10 @@ Mono<BlobDownloadAsyncResponse> downloadStreamWithResponse(BlobRange range, Down
14131413
long remainingCount = finalCount - encodedOffset;
14141414
retryRange = new BlobRange(initialOffset + encodedOffset, remainingCount);
14151415

1416+
LOGGER.info(
1417+
"Structured message smart retry: resuming from offset {} (initial={}, encoded={})",
1418+
initialOffset + encodedOffset, initialOffset, encodedOffset);
1419+
14161420
// Preserve the decoder state for the retry
14171421
retryContext = retryContext
14181422
.addData(Constants.STRUCTURED_MESSAGE_DECODER_STATE_CONTEXT_KEY, decoderState);

sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/structuredmessage/StructuredMessageDecoder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ private void readSegmentFooter(ByteBuffer buffer) {
214214
// Mark that this segment is complete - update the last complete segment boundary
215215
// This is the position where we can safely resume if a retry occurs
216216
lastCompleteSegmentStart = messageOffset;
217+
LOGGER.verbose("Segment {} complete at byte offset {}", currentSegmentNumber, lastCompleteSegmentStart);
217218

218219
if (currentSegmentNumber == numSegments) {
219220
readMessageFooter(buffer);

sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/StorageContentValidationDecoderPolicy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ public long getTotalEncodedBytesProcessed() {
305305
public long getRetryOffset() {
306306
// Use the decoder's last complete segment start as the retry offset
307307
// This ensures we resume from a segment boundary, not mid-segment
308-
return decoder.getLastCompleteSegmentStart();
308+
long retryOffset = decoder.getLastCompleteSegmentStart();
309+
LOGGER.verbose("Retry offset calculated: {} (last complete segment boundary)", retryOffset);
310+
return retryOffset;
309311
}
310312

311313
/**

0 commit comments

Comments
 (0)