[JAVA-3437] Allow connection threads to use non-default name Created: 14/Sep/19 Updated: 30/Mar/22 |
|
| Status: | Backlog |
| Project: | Java Driver |
| Component/s: | Reactive Streams |
| Affects Version/s: | 3.11.0 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Wing Tsang | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
My application is non-blocking based using Vertx / Reactor and we use slf4j to log the thread name, which is very handy for debug. However it looks like the connection threads created by the java reactive driver is using the default thread name. Can we change the mongo connection threads use non-default thread name prefix? |
| Comments |
| Comment by Jeffrey Yemin [ 09/Oct/19 ] | |||||||||||||||||||
|
Thanks for your investigation. I'll add this to our backlog, but since there appears to be a workaround (create your own AsynchronrouChannelGroup) we don't plan to fix this immediately. | |||||||||||||||||||
| Comment by Wing Tsang [ 09/Oct/19 ] | |||||||||||||||||||
|
After opening TRACE logging for mongodb driver, 2 more logs are printed under "Thread-7" by LoggingCommandEventSender 2019-10-09 12:13:03,552 DEBUG [Thread-7] org.mongodb.driver.protocol.command - Sending command '{[MASKED]}' with request id 8 to database [MASKED] on connection [connectionId\{localValue:2, serverValue:1871851}] to server [MASKED] which should be triggered by InternalStreamConnection, which is using Stream which is indirectly created by AsynchronousSocketChannelStreamFactoryFactory so it is the AsynchronousChannelGroup to control the thread name by default AsynchronousChannelGroup is null and so the threads created are just "Thread-*" I have tried to configure AsynchronousChannelGroup and the thread name can be changed accordingly. — So if it is ok for mongodb java driver to create a default AsynchronousChannelGroup with appropriate thread name prefix to indicate the threads are created by mongodb java driver internal?
| |||||||||||||||||||
| Comment by Jeffrey Yemin [ 30/Sep/19 ] | |||||||||||||||||||
|
I don't think that the Java driver is creating the thread named "Thread-7". The Java driver only creates threads for connection pool and cluster monitoring, not for execution of reactive callbacks. | |||||||||||||||||||
| Comment by Wing Tsang [ 17/Sep/19 ] | |||||||||||||||||||
|
Here is an example log:
The log starts from vertx event loop, until after subscribe and request, then is switched to the mongodb driver "Thread-7" after data is returned from querying mongodb.
| |||||||||||||||||||
| Comment by Jeffrey Yemin [ 16/Sep/19 ] | |||||||||||||||||||
|
The driver creates threads for multiple purposes. Can you share a log snippet with us to show which ones you're referring to? |