-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix flaky integration test: TestDatabaseAccessMongoConnectionCount #10869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks for the fix.
@greedy52 From what I understand the problem comes from the fact that mongo driver creates multiple TCP connections per one DB connection (if you can phrase it in this way). Have you tried to use some driver options to control that? |
@jakule I have tried |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@jakule @smallinsky as suggested by Jakub, I did some more digging into this and got some bad news. The mongo client does have a connection pool, which controls connection pool size and can be monitored by So besides the connection pool, the client also creates TWO other connections to the server that is not from this pool. For example, a background So, our mongo engine receives 3 connections per client. The worst part is we are multiplying this since we use the same driver. For each incoming connection to the engine, we establish 3 to the actual server. This multiplies. So 3 * 3 = 9. I guess one of the background tasks doesn't get caught all the time, so we are seeing 2 * 3 = 6 from time to time. I don't the multiplying effect will be an easy fix. I will create an separate issue to track |
@greedy52 can we get this backported to v9 and v8? |
Seeing this fail in CI build and it's quite easy to reproduce locally.
So problem is, per client, it may establish 6 or 9 connections. Server connection count is NOT growing one client after another, BUT getting
6 != 9
sometimes. <--- fix to userequire.InDelta
Another potential issue is we are getting server count after client disconnect. There is an race condition that server may have 0 connections or it could still have all 9 connections. <--- fix to get the server connection count before disconnect
Lastly, added one additional check to wait until the server reaches 0 connection count in the end.
Updates #9492