Open JamesHutchison opened 5 months ago
The introspection query isn't that complex and typically runs in under a millisecond on regular Postgres. This is something you might want to raise with Cockroach Labs people.
@elprans
I also get a 7 seconds delay on each connection everytime it's opened. This is really annoying given I use a connection pool. This only happends with cockroachdb it doesn't happen with postgresql.
On the other hand when using sql alchemy this problem does not occur. So I think the problem is on the side of the asyncpg library.
I reached out to CockroachDB about this.
@JamesHutchison could you please reach out to Cockroach DB support via our ticketing system: https://support.cockroachlabs.com/hc/en-us This way we can provide you with the best support. It looks like you emailed another organization within CRL. Thank you!
Created ticket
@JamesHutchison - I can see the ticket has been created but we are unsure about the organization that you are using, could you please share the organization details in the existing ticket or create the ticket with the correct organization?
Any new information on this? I still get delays everywhere in my app.
They are aware of the issue
https://github.com/cockroachdb/cockroach/issues/113292
My recommendation is to use my workaround in the meantime
@JamesHutchison I can't I get a 7 seconds delay on each connection opened to cockroachdb not just on grabbing type info. Not sure if we have the same problem, but they are probably related.
So apparently this issue might be related to asyncpg introspection queries: https://github.com/cockroachdb/cockroach/issues/128774 https://github.com/MagicStack/asyncpg/blob/85d7eed40637e7cad73a44ed2439ffeb2a8dc1c2/asyncpg/introspection.py#L14-L88
Is there a way to rollback to a version without this issue until the problem is fixed?
If you're using redis or really anything that could store the serialized result of the query, my hack works pretty well.
@JamesHutchison Not using Redis I'm afraid, hope this issue gets resolved soon. It surprises me that there are not more people with this issue.
Just save it to a file or something. Whatever (non-DB persistence you have available.
I was having atrocious and unacceptable delays in my production environment that I wasn't seeing locally, using CockroachDB cloud. Found the cause was the introspection of types. I'm using the latest version of the CockroachDB drivers.
I wrote this hack to work around the issue. It caches the result in local memory and also caches it to redis so that new instances don't see it. You can change the key for the redis cache using an environment variable so that new versions aren't locked to old values.
If someone wants to turn it into part of the product, please be my guest. I won't have time for it. In the mean time. here's the hack that does monkey patching: