-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
JWT cache is not purged? #3788
Comments
I've gotten a report that memory usage keeps increasing and is never purged but I wasn't able to reproduce this. I tried:
And monitoring the memory usage with: while ps -p $(pgrep postgrest | tail -n 1) --no-headers --format "etime %mem rss"; do sleep 5; done While repeatedly doing: curl localhost:3000/authors_only -H "Authorization: Bearer $(postgrest-gen-jwt --exp 100 postgrest_test_author)" This in theory should show postgREST process consuming more memory but it doesn't somehow. |
Another option would be to use the |
Another way could be that we can log the cache size using the |
I tried tracing the cache size by adding this body <- lift $ Wai.strictRequestBody req
trace (show (unsafePerformIO $ C.size (getJwtCache appState))) (return ()) -- here
let jwtTime = if configServerTimingEnabled then Auth.getJwtDur req else Nothing This showed a trace of the number of cache entries in the cache every time I run this:
The trace showed an increasing number of entries even after the tokens are expired. 1
2
.
.
30
31 # increases forever I am not sure if using checkCache <- C.lookup (getJwtCache appState) token
authResult <- maybe parseJwt (pure . Right) checkCache
C.purgeExpired (getJwtCache appState) -- here remove expired items and this can be confirmed by sending the above curl request again which shows the size reducing after the token is actually expired (10 seconds in this case). @steve-chavez Does this confirm that this is a bug? |
@taimoorzaeem Yes, that's a good repro. Thinking more about how to test this. We could add a |
@steve-chavez I guess having a cache metric would not be possible because metrics are initialized before the initialization of Maybe we can test this in |
I don't think there's a circular dependency problem there, we already capture Pool metrics for example, and the pool is only contained on AppState. This is one of the reasons the Observation type was added (for indirection), you'd just need to add a new constructor for this case.
Sure, go ahead. |
Oh, I understand now. The |
Problem
The
Data.Cache
says:But
purgeExpired
nor purge are called anywhere on the Auth module.The text was updated successfully, but these errors were encountered: