WSL: Socket error when using memcached as php session storage with session data over 8112 bytes
-
Your Windows build number: (Type
verat a Windows Command Prompt) 16241 -
What you’re doing and what’s happening: (Copy&paste specific commands and their output, or include screen shots)
sudo apt-get install php7.1-cli php-memcached memcached
sudo service memcached start
php -d 'session.save_handler=memcached' -d 'session.save_path=127.0.0.1' -r 'session_start();
$_SESSION["test"]=str_repeat("1", 8113); session_write_close();
- What’s wrong / what should be happening instead: upon closing the session, an error is thrown in libmemcached/io.cc and no session data stored:
Warning: Unknown: error saving session to memcached: (0x7fc6e54a9000) INVALID ARGUMENTS(Invalid argument), host: 127.0.0.1:11211 -> libmemcached/io.cc:392 in Unknown on line 0
Warning: Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (127.0.0.1:11211) in Unknown on line 0
the libmemcached used by php-memcached is 1.0.18. according to its source code, it seems to be a socket error happening when writing to the socket: https://github.com/arthurnn/memcached/blob/master/vendor/libmemcached-1.0.18/libmemcached/io.cc#L329 the threshold in the above commandline example is 8112 bytes, everything larger results in the error.
the exact same configuration including the exact same package and dependencies versions works fine in a VMWare Worstation Pro vm. using session.save_handler = file works fine in WSL.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (5 by maintainers)
@heldchen - Thanks for the post and the traces. I can confirm that
MSG_MOREis currently not implemented/supported in WSL.@therealkenc - Good eyes! Interesting correlation 😃. You may also find it interesting to know that WSL ignores the
msg_flagsfields in themsghdras per the man page. See comment about/* flags (unused) */andThe msg_flags field is ignored(which is why it is working in the other case). But, in this case,MSG_MOREis sent directly insendto. I am curious to see if Linux also ignores themsg_flagsfield inmsghdras it says in the man page.Also, the other interesting question here is, what will be the impact (compat) of ignoring
MSG_MOREflag? I am less concerned about stream based connection-oriented sockets, as is this case here. But, more concerned about compat on UDP sockets. Stubbing it out might unblock the scenario in this case though. Time to do some experiments 😃@heldchen - Great! Thanks for the confirmation.
this seems to have made it into build 16257 - I cannot repo the error anymore. thanks @sunilmut
@heldchen - I stubbed
MSG_MOREin WSL for TCP and it seemed to have unblocked this particular scenario. I am not very comfortable stubbing it for UDP. But, I will try to get this change in.Note that on WSL, you will have to explicitly start the
memcachedservice because WSL does not yet support auto-start of services.It’s also funny that Java is sending so many flags under
msg_flags😃Interestingly
MSG_NOSIGNAL|MSG_MOREdoes take withsendmmsg(), at least in some scenarios. Saw it just last week here. So I speculate it is the “..., NULL, 0” not the flags. Could be wrong. Thanks for the follow-up.so it is the
MSG_MOREparameter ofsendto. with smaller session sizes, onlyMSG_NOSIGNALis used:recvfrom(4, "\201\f\0$\4\0\0\0\0\0\0(\0\3\0\0\0\0\0\0\0\0\374\275\0\0\0\0memc"..., 8196, MSG_NOSIGNAL, NULL, NULL) = 64