code: private void mergeCompleted(SegmentProperties segmentProperties, UpdateableSegmentMetadata transactionMetadata, MergeSegmentOperation mergeOp) {
          // We have processed a MergeSegmentOperation, pop the first operation off and decrement the counter.
          StorageOperation processedOperation = this.operations.removeFirst();
          assert processedOperation != null && processedOperation instanceof MergeSegmentOperation : "First outstanding operation was not a MergeSegmentOperation";
          MergeSegmentOperation mop = (MergeSegmentOperation) processedOperation;
          assert mop.getSourceSegmentId() == transactionMetadata.getId() : "First outstanding operation was a MergeSegmentOperation for the wrong Transaction id.";
          int newCount = this.mergeTransactionCount.decrementAndGet();
          assert newCount >= 0 : "Negative value for mergeTransactionCount";
  
          // Post-merger validation. Verify we are still in agreement with the storage.
          long expectedNewLength = this.metadata.getStorageLength() + mergeOp.getLength();
          if (segmentProperties.getLength() != expectedNewLength) {
              throw new CompletionException(new DataCorruptionException(String.format(
                      "Transaction Segment '%s' was merged into parent '%s' but the parent segment has an unexpected StorageLength after the merger. Previous=%d, MergeLength=%d, Expected=%d, Actual=%d",
                      transactionMetadata.getName(),
                      this.metadata.getName(),
                      segmentProperties.getLength(),
                      mergeOp.getLength(),
                      expectedNewLength,
                      segmentProperties.getLength())));
          }
  
          updateMetadata(segmentProperties);
          updateMetadataForTransactionPostMerger(transactionMetadata, mop.getStreamSegmentId());
      }
docs: Executes post-Storage merge tasks, including state and metadata updates.