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

Why do we use param["url"] as a unique connection pool key? #685

Open
calamont opened this issue Oct 10, 2023 · 5 comments
Open

Why do we use param["url"] as a unique connection pool key? #685

calamont opened this issue Oct 10, 2023 · 5 comments
Labels

Comments

@calamont
Copy link

calamont commented Oct 10, 2023

Hey all 🙂

I'm wondering if there was delibrate reason param["url"] was chosen as the connection pool key in the ConnectionFactory? Two cache configurations could still have the same URL. Once the first connection is created, any subsequent request will use the first parameters applied, regardless of which cache alias is requested from django.core.cache.caches.

If this is not desired behaviour I can open an PR to provide a workaround.

Thanks!

@WisdomPill
Copy link
Member

might be a slip up, I did not create the library myself, I inherited it,
but I see your point here and I welcome any PR to solve the issue.

Just to be sure, you're referring to some options that could be used with some alias and not the others?

@calamont
Copy link
Author

calamont commented Nov 4, 2023

you're referring to some options that could be used with some alias and not the others?

Yeah. The use case I came up against was configuring two different timeouts. It seemed creating two aliases for these different configurations was the way forward (correct me if there is another approach I didn't see).

Because of the issue I described above, if the app used one timeout in one flow, any subsequent connection pool would use that timeout, even if the other alias was specified. The app is a monolith that uses a shared Elasticache instance, so there are a few flows were timeouts can be more generous.

I can raise a PR with the solution I ended up applying on my end, though there could be a better approach :)

@WisdomPill
Copy link
Member

are we talking about the default timeout of an arbitrary key? or something at the connection level, like socket timeout?

@calamont
Copy link
Author

calamont commented Nov 4, 2023

Sorry, I meant the socket timeout and socket connect timeout.

@WisdomPill
Copy link
Member

got it, please feel free to submit a PR and I will be happy to review it and merge it, also any feedback on the setup for the local development is welcome 😄

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

No branches or pull requests

2 participants