Github user adeneche commented on a diff in the pull request: https://github.com/apache/drill/pull/283#discussion_r46493263 --- Diff: exec/memory/base/src/main/java/io/netty/buffer/DrillBuf.java --- @@ -230,20 +249,31 @@ public synchronized boolean release() { */ @Override public synchronized boolean release(int decrement) { + if (isEmpty) { + return false; + } - if(rootBuffer){ - final long newRefCnt = this.rootRefCnt.addAndGet(-decrement); - Preconditions.checkArgument(newRefCnt > -1, "Buffer has negative reference count."); - if (newRefCnt == 0) { - b.release(decrement); - acct.release(this, length); - return true; - }else{ - return false; - } - }else{ - return b.release(decrement); + if (decrement < 1) { + throw new IllegalStateException(String.format("release(%d) argument is not positive. Buffer Info: %s", + decrement, toVerboseString())); } + + if (BaseAllocator.DEBUG) { + historicalLog.recordEvent("release(%d)", decrement); --- End diff -- I think it would be helpful to also record the new `refCnt`
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---