Resolution: Works as Designed
Affects Version/s: 4.7.1
JAVA-4684, since Mongo driver v4.7.1 you should get a mongo exception with TransientTransactionError label. In practice the java's SocketException gets thrown.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
Here is what server configuration MongoDB Compass shows to me:
Cluster: Replica Set (atlas-example-shard-0), 3 Nodes
Edition: MongoDB 5.0.10 Enterprise
Driver version 4.7.1
Using the latest Spring boot 2.7.2 app from start.spring.io template, deployed to Azure AKS + and the latest Mongo driver 4.7.1. As you can see, the app is primitive: there is a simple read with @Transactional
Unfortunately, I do not know how to reproduce exactly the same SocketException. I still do not know the root cause of the network problem in connection between the app and the db. This connection problem appears only when the app is deployed to k8s cluster and connected to Atlas MongoDB instance.
But I know the steps to 100% reproduce this exception in this Azure AKS cluster:
- deploy an app
- make sure the /top10Events responds as expected
- do not touch an app for ~ 45 miuntes
- try invoking /top10Events again and you will get the java.net.SocketException from Mongo driver instance instead of the mongo exception with TransientTransactionError label. Before 4.7.1 driver you would get an exception mentioned in
Below you can see the complete stacktrace of unexpected java.net.SocketException with 4.7.1 driver. There is also the complete piece of log attached (see attached debug-exception-public.txt) with debug info for org.mongodb.driver and org.springframework.data.mongodb