luckyframework / avram

A Crystal database wrapper for reading, writing, and migrating Postgres databases.
https://luckyframework.github.io/avram/
MIT License
165 stars 64 forks source link

Cache pollution across requests in development #804

Open robacarp opened 2 years ago

robacarp commented 2 years ago

I'm seeing cache objects bleed over between requests on Avram release v0.22.0 with query cache enabled. This might be related to #803. I disabled turbolinks to validate there was nothing strange happening on the front end, but the issue persists.

I don't have a lot of clever code going on. It's a server rendered page, traditional form submits, etc. Nothing fancy.

This sequence repeatedly produces ghost artifacts:

GET resource/:id/subresource_index DELETE subresource/:id -> 301 redirect to resource/:id/subresource_index GET resource/:id/subresource_index

To be a little more concrete: GET posts/:id/comments DELETE comment/:id -> 301 redirect to posts/:id/comments GET posts/:id/comments

The second index fetch will reliably still have the deleted comment. Frequently the comment persists until the server recompiles.

jwoertink commented 2 years ago

It turns out that there's a few different cases when a Fiber can leak across requests. What Athena does is sets a new instance on the current fiber within an HTTP handler https://github.com/athena-framework/athena/blob/master/src/components/framework/src/athena.cr#L152-L153

I think we will need to do something similar.