Reproduce
Ran modified ConcurrencyTest.java referenced in DRILL-4338 and cancel after 2-3 seconds. ConcurrencyTest.java should be modified as follows:ExecutorService executor = Executors.newFixedThreadPool(10); and execute 200 queries for (int i = 1; i <= 200; i++).
Query: select * from dfs.`sample.json`, data set is attached.

Problem description
Looks like the problem occurs when the server has sent data to the client and waiting from the client confirmation that data was received. In this case ChannelListenerWithCoordinationId is used for tracking. ChannelListenerWithCoordinationId contains StatusHandler which keeps track of sent batches. It updates SendingAccountor with information about how many batches were sent and how many batches have reached the client (successfully or not).

When sent operation is complete (successfully or not) operationComplete(ChannelFuture future) is called. Given future contains information if sent operation was successful or not, failure cause, channel status etc. If sent operation was successful we do nothing since in this case client sent us acknowledgment and when we received it, we notified StatusHandlerListener that batch was received. But if sent operation has failed, we need to notify StatusHandler that sent was unsuccessful.

Method setException notifies StatusHandler that batch sent has failed but it's only called when channel is closed. When channel is still open we just throw RpcException. This is where the problem occurs. operationComplete(ChannelFuture future) is called via Netty DefaultPromise.notifyListener0 method which catches Throwable and just logs it. So even of we throw exception nobody is notified about it, especially StatusHandler.

Fix
Use setException even if channel is still open instead of throwing exception.

This problem was also raised in PR-463 but was decided to be fixed in the scope of new Jira.