ISSUE #2563: Fix SST file corruption.

Fix SST File corruption during checkpointing

### Motivation

Since the SST files are shared among checkpoints, this will not be resolved by future checkpoints. We will fail to restore all future checkpoints that depend on this file.

### Changes

The record is sent asynchronously. We need to use a copy of the passed buffer
in the record. The ownership is retained by the caller and will be potentially
changed by the caller. In case of corruption the later blocks were
overwriting the previous blocks resulting in corruption


Master Issue: #2563 



Reviewers: Andrey Yegorov <None>, Enrico Olivelli <eolivelli@gmail.com>, Matteo Merli <mmerli@apache.org>

This closes #2564 from sursingh/fix-sst-corruption, closes #2563
diff --git a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLOutputStream.java b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLOutputStream.java
index 834dd62..8b229df 100644
--- a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLOutputStream.java
+++ b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLOutputStream.java
@@ -95,7 +95,7 @@
         }
 
         writePos += buf.readableBytes();
-        LogRecord record = new LogRecord(writePos, buf);
+        LogRecord record = new LogRecord(writePos, buf.copy());
         writer.write(record).whenComplete(new FutureEventListener<DLSN>() {
             @Override
             public void onSuccess(DLSN value) {