-
Notifications
You must be signed in to change notification settings - Fork 11
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
"Cache token has expired" error #1
Comments
Which cache driver do you use? Maybe your cache doesn't handle the expiration date correctly. |
I'm using Redis. |
Maybe this is an issue with the time zone (i.e. your app has a different timezone than OVH servers, ref). Could this be the case? To confirm this, you could add the following line here in your installed laravel-cached-openstack source: logger('Token', ['original' => $token->expires, 'cached' => new DateTime($cachedToken['expires_at'])]); Then clear the cache, perform some call to OpenStack and post the new lines added to your application logfile here. |
I was just digging in the same code. Yes, my server is indeed in different timezone than the one returned from the OVH API call, but using Output from the logger is: If I use I run backups every hour so maybe when the token is generated and valid for the next 24 hours it exceeds that time right after my backup starts 24h later. I'll try to subtract 5 minutes from |
Yes but laravel-cached-openstack uses the string representation of the expiration date which does not include timezone information and probably is not converted. I see that your log entry contains |
Yes, I pasted the code that you provided and that's the output. But given the correct TTL in Redis, it's all good. The token will be removed from cache excatly when I'm pretty sure right now that I run into this rare edge case because I run my backups regularly every hour. And given the fact that it's not happening every 24h but once within few days, it's probably it. I've added the code to subtract 5 minutes from that time and we'll see. |
I'm not 100% convinced yet. And subtracting 5 min is a workaround at best. Please leave this issue open, I want to do a few tests myself when I have some time. |
Ok, sure. But what if the problem is between grabbing the token from the cache and calling $token->hasExpired() Imagine a scenario like this (and that's what's happening on my server):
Of course PHP runs that code very fast but I think this could be what's happening although it sounds unlikly. From a logical standpoint it's possible if we think about how much thought is being put into things like "atomic symlink" in Linux etc. |
Ah, now I see what you mean. This is indeed an edge case when your backup interval matches exactly to the time the token is valid. This also explains why the error occurred only sometimes for you. Now I'm convinced 😉 Then maybe it's best to always subtract a minute or so from the TTL in the cache. I'll see that I update laravel-cached-openstack accordingly. |
Exactly. And that wouldn't be an issue for other users since your driver gives them ability not to call the API for the new token for 24h (or another time depending on the response) so if it will be 1 minute less it shouldn't be a problem. Of course it's your call if you update the package but it would be awesome to have the ability to pull the newest version and forget about that problem which I'm almost sure we diagnosed here. If you want to wait, I'll be testing this out with -5 minutes for the next few days. |
I intend to update the package but I won't have time for that in the next few days. Please report back if the change fixed the issue for you. Feel free to open a pull request to laravel-cached-openstack if it does. |
Ok, will do. Thank you for your help. |
There is an edge case causing token to expire right before its validity is checked. It's discussed here: mzur/laravel-openstack-swift#1 This commit fixes that issue by storing the token in the cache for 1 minute less than it's valid.
Problem solved here: https://github.com/biigle/laravel-cached-openstack/releases/tag/v1.0.1 |
Hi,
thank you for creating and maintaining this great driver. It's been really useful. I have one problem though.
I have configured automatic backup using laravel-backup and OVH Public Cloud Object Storage (it uses OpenStack Swift). It works just fine but after some time I get this error: "Cached token has expired on [date]".
I was about to open an issue here when I found out that you added laravel-cached-openstack and I was hoping that it would fix that issue. Unfortunately it didn't.
Is it anything I could change in my configuration or is it something that you have to fix in this driver?
Thanks
The text was updated successfully, but these errors were encountered: