@@ -245,8 +245,8 @@ public <K, V, T> RedisCommand<K, V, T> write(RedisCommand<K, V, T> command) {
245
245
command = processActivationCommand (command );
246
246
}
247
247
248
- QUEUE_SIZE .incrementAndGet (this );
249
248
this .taskQueue .offer (command );
249
+ QUEUE_SIZE .incrementAndGet (this );
250
250
251
251
if (autoFlushCommands ) {
252
252
flushCommands ();
@@ -788,6 +788,7 @@ private void offerFirstAll(Deque<RedisCommand<?, ?, ?>> commands) {
788
788
}
789
789
});
790
790
this .taskQueue .offerFirstAll (commands );
791
+ QUEUE_SIZE .addAndGet (this , commands .size ());
791
792
}
792
793
793
794
private void cancelCommands (String message ) {
@@ -818,6 +819,7 @@ private final void fulfillCommands(String message, Consumer<RedisCommand<?, ?, ?
818
819
}
819
820
}
820
821
822
+ int cancelledTaskNumInTaskQueue = 0 ;
821
823
while (true ) {
822
824
RedisCommand <?, ?, ?> cmd = this .taskQueue .poll ();
823
825
if (cmd == null ) {
@@ -827,9 +829,12 @@ private final void fulfillCommands(String message, Consumer<RedisCommand<?, ?, ?
827
829
cmd .getOutput ().setError (message );
828
830
}
829
831
commandConsumer .accept (cmd );
832
+
833
+ cancelledTaskNumInTaskQueue ++;
830
834
totalCancelledTaskNum ++;
831
835
}
832
836
837
+ QUEUE_SIZE .addAndGet (this , -cancelledTaskNumInTaskQueue );
833
838
if (totalCancelledTaskNum > 0 ) {
834
839
logger .error ("{} cancel {} pending tasks, reason: '{}'" , logPrefix (), totalCancelledTaskNum , message );
835
840
}
0 commit comments