Impossible to correlate logs from NIO worker threads
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 400
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Description
### Version
2.18.0
### Bug description
Hi,
We have sometimes the need to enable DEBUG logs to see what is happening in more details, the window adjustment messages etc... to investigate issues. Lately we have a problem with a server where some connections are fast, we create different channels in the same sessions, and they are all slow but if we create a new connections, it is fast. As a workaround we have implemented a way to renew the connections if it is opened for more than x minutes.
And when we open new session, then the transfer is fast again. It is really hard to understand what could cause this slowness, for that we enabled debug logs on mina, but we do not know how to correlate the logs from nio threads as we loose the mdc context and we have a lot of different logs!
Is there a way to correlate the logs ?
I know there are listeners that we could implement but obviously it does not cover all cases.
### Actual behavior
Lot of logs from different threads without common client session identifier
### Expected behavior
Be able to propagate MDC context to correlate logs
### Relevant log output
```Shell
[sshd-SshClient[f237ae7]-nio2-thread-1][common-transfer] DEBUG o.a.s.c.s.ClientSessionImpl doHandleMessage(ClientSessionImpl[adds.user@localhost/127.0.0.1:62253]) process #5 SSH_MSG_CHANNEL_OPEN_CONFIRMATION
2026-06-24 12:37:30,656 [sshd-SshClient[f237ae7]-nio2-thread-1][common-transfer] DEBUG o.a.s.c.s.ClientConnectionService channelOpenConfirmation(SftpChannelSubsystem[id=0, recipient=-1]-ClientSessionImpl[adds.user@localhost/127.0.0.1:62253][sftp]) SSH_MSG_CHANNEL_OPEN_CONFIRMATION sender=0, window-size=2097152, packet-size=32768
2026-06-24 12:37:30,656 [sshd-SshClient[f237ae7]-nio2-thread-1][common-transfer] DEBUG o.a.s.s.c.i.DefaultSftpClient$SftpChannelSubsystem setRecipient(SftpChannelSubsystem[id=0, recipient=-1]-ClientSessionImpl[adds.user@localhost/127.0.0.1:62253][sftp]) recipient=0
2026-06-24 12:37:30,656 [sshd-SshClient[f237ae7]-nio2-thread-1][common-transfer] DEBUG o.a.s.c.c.RemoteWindow init(RemoteWindow[client](SftpChannelSubsystem[id=0, recipient=0]-ClientSessionImpl[adds.user@localhost/127.0.0.1:62253][sftp])) size=2097152, max=2097152, packet=32768
```
### Other information
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
No source files or tests are named. Start by tracing how NIO worker threads dispatch session and channel work, then inspect where MDC context is lost; done means logs from a client session carry a common session identifier, with coverage for the worker-thread path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100