-
Notifications
You must be signed in to change notification settings - Fork 438
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
[Spanner] Re-create sessions that have been invalidated by the server #6284
Comments
Do you have scenarios when there are accumulated deleted sessions? |
Hi, thanks for looking into the issue.
We have seen this error numerous times in production through out the years on queue workers. Btw, if you look at colopl/laravel-spanner#37, #1808, at least 4 other people have encountered the same error.
In order to fix this, we had to make many changes to our existing code. It took way more effort than it should have because, we couldn't find a way to delete a single session from the session pool. The only way to resolve it was to delete the entire session pool which was less than ideal. We wasted many hours testing and confirming that clearing the entire cache wouldn't break anything. Would it be possible to at least expose a method which will allow end user to delete the currently used session? |
@taka-oyama I can reproduce |
One generic case where
Below is the code I used to confirm this. $sessionPool = new CacheSessionPool(
new SysVCacheItemPool(),
['minSessions' => 1],
);
$database = (new SpannerClient())->connect(
"my-instance",
"my-database",
['sessionPool' => $sessionPool],
);
$database->execute('SELECT 1')->rows()->current();
$timeout = strtotime('+2 hours');
while($timeout > time()) {
$sessionPool->maintain();
sleep(1800); // 30 min
}
$database->execute('SELECT 1')->rows()->current(); This happens because the session is never returned to the session pool. I understand that session should be returned by closing the connection when the connection is idle but I'm afraid most people don't realize it needs to be done. |
Hi @taka-oyama, maintain renews the sessions that are about to go stale in next ~10 mins. So, if you call the above code with Yet to test this though. |
Re-tested this and it seems even with a reduced sleep time, |
I think I know what's happening here. Checking internally whether there's any particular reason to whether we should purge/refresh in-use sessions. |
So, it seems maintain is not supposed to handle the Closing since no action. |
I was reading through the documentation on Sessions and noticed the following line.
Currently, this is not possible from userland because there is no public method available to delete the current session.
Would it be possible to handle this on the library side?
I found that this is handled by the library in google-cloud-java googleapis/google-cloud-java#4734.
Here is another example from google-cloud-go googleapis/google-cloud-go#1527.
Creating a case where the server throws a "NOT FOUND" exception can be reproduced by following the steps on #5827.
The text was updated successfully, but these errors were encountered: