Skip to content

Commit

Permalink
Fixed refcounting when processing entries from sql (apache#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Aug 7, 2018
1 parent 9213e58 commit 6b7a76f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,10 @@ public static void parseMessage(TopicName topicName, long ledgerId, long entryId
if (numMessages == 1 && !msgMetadata.hasNumMessagesInBatch()) {
final MessageImpl<?> message = new MessageImpl<>(msgId, msgMetadata, uncompressedPayload, null, null);
processor.process(msgId, message, uncompressedPayload);

uncompressedPayload.release();

} else {
// handle batch message enqueuing; uncompressed payload has all messages in batch
receiveIndividualMessagesFromBatch(msgMetadata, uncompressedPayload, messageId, null, -1, processor);
uncompressedPayload.release();
}

} finally {
if (uncompressedPayload != null) {
uncompressedPayload.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED;
import static com.facebook.presto.spi.type.BigintType.BIGINT;
Expand Down Expand Up @@ -202,10 +201,9 @@ public boolean advanceNextPosition() {
throw new RuntimeException(e);
}

newEntries.forEach(new Consumer<Entry>() {
@Override
public void accept(Entry entry) {
completedBytes += entry.getData().length;
newEntries.forEach(entry -> {
try {
completedBytes += entry.getDataBuffer().readableBytes();
// filter entries that is not part of my split
if (((PositionImpl) entry.getPosition()).compareTo(pulsarSplit.getEndPosition()) < 0) {
try {
Expand All @@ -217,9 +215,9 @@ public void accept(Entry entry) {
log.error(e, "Failed to parse message from pulsar topic %s", topicName.toString());
throw new RuntimeException(e);
}
} else {
entry.release();
}
} finally {
entry.release();
}
});
}
Expand Down

0 comments on commit 6b7a76f

Please sign in to comment.