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
However, when the number of users on the game server increases, the following error occurs in SysVCacheItemPool:
shm_put_var(): Not enough shared memory left
Investigating the cause, it seems that when multiple accesses are made to PHP's shared memory with shm_put_var simultaneously, the error occurs. The following script reproduces the issue easily:
<?php$shmid = shm_attach(1001, 1024 * 1024, 0666);
if (!$shmid) {
die("Failed to create shared memory segment\n");
}
$variableKey = 1;
while (true) {
$result = shm_put_var($shmid, $variableKey, ["only one"]);
if (!$result) {
echo"Failed to put variable into shared memory\n";
break;
}
}
shm_detach($shmid);
Regarding the comment in SysVCacheItemPool:
This CacheItemPool implementation can be used among multiple processes, but it doesn't provide any locking mechanism. If multiple processes write to this ItemPool, you have to avoid race condition manually in your code.
I created a LockedSysVCacheItemPool that uses a locking mechanism (similar to the one used in CacheSessionPool) for writing to the shared memory, and this resolved the issue. Here is the code:
This solution seems to have resolved the shm_put_var(): Not enough shared memory left error in my environment. I am reporting this here just in case others are facing the same issue.
Additionally, this may be related to the following issues: #225 #226
If a pull request from me is necessary, I can create one.
Please note that since I am not fluent in English, I have used an AI to translate this message for me.
The text was updated successfully, but these errors were encountered:
Environment details
Hello,
I am using the
google/cloud-spanner
library to connect my PHP game server to Spanner. The code snippet below shows how I connect to Spanner:However, when the number of users on the game server increases, the following error occurs in
SysVCacheItemPool
:Investigating the cause, it seems that when multiple accesses are made to PHP's shared memory with
shm_put_var
simultaneously, the error occurs. The following script reproduces the issue easily:Regarding the comment in
SysVCacheItemPool
:I created a
LockedSysVCacheItemPool
that uses a locking mechanism (similar to the one used inCacheSessionPool
) for writing to the shared memory, and this resolved the issue. Here is the code:And here is the updated Spanner client configuration:
This solution seems to have resolved the
shm_put_var(): Not enough shared memory left error
in my environment. I am reporting this here just in case others are facing the same issue.Additionally, this may be related to the following issues:
#225
#226
If a pull request from me is necessary, I can create one.
Please note that since I am not fluent in English, I have used an AI to translate this message for me.
The text was updated successfully, but these errors were encountered: