Error happens quite rarely and is not easy to reproduce. Although the problem was partly fixed by fixing
QPID-8477, it still can be reproduced. The main symptom is significant increase of CPU usage even when no messages are sent to broker anymore. CPU usage can rise from 30% to 90% and higher, making broker unusable. After such CPU rise the only way to fix broker will be restarting it.
Analysis has shown, that error occurs with CPP proton client in cases when
1) SSL connection is used
2) connection errors on client side are ignored
3) connection is dropped due to the client process termination / network disconnection
Steps to reproduce
- Java broker should be installed
- Broker should be configured to allow one connection
- Prepare certificates
- Install Qpid::Proton 0.28.0
mkdir -p qpid-proton-0.28.0/build && pushd qpid-proton-0.28.0/build && cmake .. && make all && popd
- Replace and edit example qpid-proton-0.28.0/cpp/examples/simple_recv.cpp with the one attached
- Build again
- Break the broker
./cpp/examples/simple_recv & ./cpp/examples/simple_recv
^C <= Hit Ctrl+C to kill process
- If CPU usage didn't increased, find the PID of the first simple_recv process using ps-ef | grep simple_recv and kill it using kill -9 PID.
CPU usage rises when connection is dropped on the client side or when network is broken between client and broker. The main point is that client isn't well behaved and connection shouldn't be closed correctly.
On broker side connection becomes "orphaned": it is still maintained by broker, but no real reading / writing is performed. Following method calls are performed in an endless loop for each "orphaned" connection:
As there nothing physically read or written, both methods NonBlockingConnection.doRead() and NonBlockingConnection.doWrite() execute very fast (several milliseconds) without any blocking processes and after that connection is immediately rescheduled for processing in NetworkConnectionScheduler. After that loop repeats.
As the connection lifecycle is normal, there is logged nothing unusual or suspicious (nothing is seen in log at all).
In thread dump (see attachment) there is seen, that utilized are mostly thread with names virtualhost-default-iopool-XX. Typical stacktrace looks like following:
The main symptom of an error is rising CPU usage, which can reach up to 90% in case, when several connections are "orphaned". Additional factor leading to the problem is disabled keep-alive option for a connection or long keep-alive interval.