You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we had issues using the default setup for a use case where we want to execute some code on a read only connection. a short example is below. evidently this would not work if the normal connection pool is used because the cache would not be able to write, which indeed is what we where observring.
first remark is that this initially surprised us, and might make sense to add some documentation and/or warnings around the use of the standard connection pool.
the solution we are implementing tries to fix this without introducing a separate database as this would be to costly (we are running on heroku still).
the gist is to configure a cache db that points to the same database URL, something like below
HOWEVER to our surprise in the first approach (read only connection) and the second approach (rollback), in both cases, the cache entry is 'lost' after the transaction on the main db is finished/rolledback.
so somehow, the 'transaction' on the primary database seems to be impacting the transaction on the cache database?
in our case, it is actually the same database 'admitted', but there is a separate database pool (which seems to be correct) and hence the one transaction should not influence the cache writing ?
The text was updated successfully, but these errors were encountered:
koenhandekyn
changed the title
tranaction behaviour inside another connection
Tranaction behaviour inside another transaction from another connection
Apr 4, 2024
koenhandekyn
changed the title
Tranaction behaviour inside another transaction from another connection
Transaction behaviour inside another transaction from another connection
Apr 5, 2024
Hi @koenhandekyn - I've tried to reproduce this and I'm not seeing the same behaviour. As long as the cache connection and the connection used by the User class are different, then as you say a rollback on the User connection shouldn't affect the cache connection.
You could check by outputting the object ids of the connections - User.connection.object_id and SolidCache::Entry.connection.object_id. They should be different.
If they are different then it might be worth checking they are different connections at the server as well - puts User.connection.select_all("select pg_backend_pid()") and puts SolidCache::Entry.connection.select_all("select pg_backend_pid()").
interesting. in the mean time we did some updates, and somehow it impacted because i can't replicate the issue. it's nicely handled now. both variants.
we had issues using the default setup for a use case where we want to execute some code on a read only connection. a short example is below. evidently this would not work if the normal connection pool is used because the cache would not be able to write, which indeed is what we where observring.
first remark is that this initially surprised us, and might make sense to add some documentation and/or warnings around the use of the standard connection pool.
the solution we are implementing tries to fix this without introducing a separate database as this would be to costly (we are running on heroku still).
the gist is to configure a cache db that points to the same database URL, something like below
and solid cache yml
the good news is it doesn't crash any more. the system
we actually see the upsert happening:
HOWEVER to our surprise in the first approach (read only connection) and the second approach (rollback), in both cases, the cache entry is 'lost' after the transaction on the main db is finished/rolledback.
so somehow, the 'transaction' on the primary database seems to be impacting the transaction on the cache database?
in our case, it is actually the same database 'admitted', but there is a separate database pool (which seems to be correct) and hence the one transaction should not influence the cache writing ?
The text was updated successfully, but these errors were encountered: