Skip to content
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

maxIdleTimeMS support #272

Open
bc291 opened this issue Oct 5, 2020 · 4 comments
Open

maxIdleTimeMS support #272

bc291 opened this issue Oct 5, 2020 · 4 comments

Comments

@bc291
Copy link

bc291 commented Oct 5, 2020

As far I can see in the code, maxIdleTimeMS option (url) is currently skipped (as well as keepalive). This is causing idle connection issues on Azure which suggests adding maxIdleTimeMS=120000 to connection string. Is it currently considered while connecting? Should I take care about these options or just let it reconnect again, re-issue query after AutoReconnect exception?

@IlyaSkriblovsky
Copy link
Contributor

I can't say for sure, need to check the code if this setting is considered. But I think connection will reestablish automatically if dropped due to idleness.

Are your connections really idle? Do you send queries so rarely? I mean are you sure these issues are really caused by maxIdleTimeMS?

Btw, are you using MongoDB or CosmosDB? If latter, please try this version of TxMongo: #261 . CosmosDB doesn't support legacy version of Mongo's wire protocol. This PR adds support for newer protocol.

@bc291
Copy link
Author

bc291 commented Oct 5, 2020

Thanks for fast reply!
I'm using CosmosDB and will try your solution. Thanks!

Here is what I've also noticed (while using legacy wire protocol):
When the server fresh starts, few documents are persisted to db, but after some time (+- 5 minutes), it just blocks. Then it takes 25 minutes for twisted to understand that something bad happened - it notifies multiple: Failure: pymongo.errors.AutoReconnect: TxMongo lost connection to MongoDB. From this time point everything repeats. Few documents persisted, block, restoring connection after 25 min. Very strange.

Also, I'm using only insert_one and update_one so I'm wondering if your fix will change anything in my case :(
EDIT: it did not work.

@bc291 bc291 changed the title Support of maxIdleTimeMS Support for maxIdleTimeMS Oct 5, 2020
@bc291 bc291 changed the title Support for maxIdleTimeMS maxIdleTimeMS support Oct 5, 2020
@bc291
Copy link
Author

bc291 commented Oct 6, 2020

After some investigations, I've noticed that tx-mongo receives pings uninterruptedly for the whole time, but somehow during that, deferred are not resolving themselves (no callback is present) for a very long time and eventually connectionLost is invoked.

@IlyaSkriblovsky
Copy link
Contributor

IlyaSkriblovsky commented Oct 9, 2020

Is it possible to reproduce the issue with some minimal script?

It would be great if you can give me access to a test instance of CosmosDB so I could try to reproduce and investigate the issue. Unfortunately, I cannot simply create CosmosDB instance by myself because Azure don't work with private persons from Russia, as far as I know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants