Note the conflict between php5.4 and php-redis

Source: Internet
Author: User
Tags lstat connection reset
Records conflicts between php5.4 and php-redis. recently, due to the ubuntu update source, some lib conflicts between the original new source and the local system Library, leading to abnormal display on the system desktop, php5.4.9 is installed, redis, php-redis extension, and php-redis extension 2 and 10 are also installed. However, as soon as the original project is put up, nginx & nbsp; 5 records the solution to the conflict between php5.4 and php-redis.

Recently, the ubuntu source is updated, causing some lib conflicts between the new source and the local system Library. as a result, the system desktop displays an exception. later, only the new version is installed, php5.4.9 is installed, and redis is installed, php-redis extension, php-redis extension 2, 10. However, once the original project is put up, the nginx 502 error will be reported (nginx 502 error is a headache ). View nginx logs

[Error] 29229 #0: * 1403 recv () failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server:

Do not know the cloud. Then open the php-fpm error log to get the log

[21:22:23] WARNING: [pool www] child 12026 exited on signal 11 (SIGSEGV-core dumped) after 5.997917 seconds from start

[21:22:23] NOTICE: [pool www] child 12034 started

It is certain that php-fpm restarts a process after a time point. There is no clue. I searched the internet a lot and found a useful tracking method.

1. set php-fpm to start only one work process.

2. restart php-fpm and run ps aux | grep php-fpm to get the work process id pid.

3. strace-p pid

The following is my information.

Getcwd ("/home/www/wms2.xxxx.com", 4096) = 26

Lstat ("/home/www/wms2.xiaomi.com/./RWebUser.php", 0x7ffff4e30a10) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xiaomi.com/protected/vendor/wms/api/RWebUser.php", 0x7ffff4e30a10) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xiaomi.com/protected/vendor/wms/RWebUser.php", 0x7ffff4e30a10) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xiaomi.com/protected/extensions/log/RWebUser.php", 0x7ffff4e30a10) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xiaomi.com/protected/modules/rights/components/RWebUser.php", {st_mode = S_IFREG | 0777, st_size = 2945,...}) = 0

Lstat ("/home/www/wms2.xiaomi.com/protected/modules/rights/components", {st_mode = S_IFDIR | 0777, st_size = 4096,...}) = 0

Lstat ("/home/www/wms2.xiaomi.com/protected/modules/rights", {st_mode = S_IFDIR | 0777, st_size = 4096,...}) = 0

Lstat ("/home/www/wms2.xiaomi.com/protected/modules", {st_mode = S_IFDIR | 0777, st_size = 4096,...}) = 0

Open ("/home/www/wms2.xiaomi.com/protected/modules/rights/components/RWebUser.php", O_RDONLY) = 5

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2945,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2945,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2945,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2945,...}) = 0

Mmap (NULL, 2945, PROT_READ, MAP_SHARED, 5, 0) = 0x7fd9b4804000

Mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,-1, 0) = 0x7fd9b442f000

Munmap (0x7fd9b4804000, 2945) = 0

Close (5) = 0

Getcwd ("/home/www/wms2.xxx.com", 4096) = 26

Lstat ("/home/www/wms2.xxx.com/./XMCCacheHttpSession.php", 0x7ffff4e31060) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xxx.com/protected/vendor/wms/api/XMCCacheHttpSession.php", 0x7ffff4e31060) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xxx.com/protected/vendor/wms/XMCCacheHttpSession.php", 0x7ffff4e31060) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xxx.com/protected/extensions/log/XMCCacheHttpSession.php", 0x7ffff4e31060) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xxx.com/protected/modules/rights/components/XMCCacheHttpSession.php", 0x7ffff4e31060) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xxx.com/protected/modules/rights/XMCCacheHttpSession.php", 0x7ffff4e31060) =-1 ENOENT (No such file or directory)

Lstat ("/home/www/wms2.xxx.com/protected/components/XMCCacheHttpSession.php", {st_mode = S_IFREG | 0777, st_size = 2612,...}) = 0

Open ("/home/www/wms2.xxx.com/protected/components/XMCCacheHttpSession.php", O_RDONLY) = 5

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2612,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2612,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2612,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2612,...}) = 0

Mmap (NULL, 2612, PROT_READ, MAP_SHARED, 5, 0) = 0x7fd9b4804000

Munmap (0x7fd9b4804000, 2612) = 0

Close (5) = 0

Sendto (4, "get 6cacd9674ad21aa083b5032b1a29"..., 39, MSG_DONTWAIT | MSG_NOSIGNAL, NULL, 0) = 39

Recvfrom (4, 0x2806d88, 8196, 64, 0, 0) =-1 EAGAIN (Resource temporarily unavailable)

Poll ([{fd = 4, events = POLLIN}], 1, 5000) = 1 ([{fd = 4, revents = POLLIN}])

Recvfrom (4, "VALUE 6cacd9674ad21aa083b5032b1a"..., 8196, MSG_DONTWAIT, NULL, NULL) = 128

Lstat ("/home/www/wms2.xxx.com/yii/web/CHttpCookie.php", {st_mode = S_IFREG | 0777, st_size = 2772,...}) = 0

Lstat ("/home/www/wms2.xxx.com/yii/web", {st_mode = S_IFDIR | 0777, st_size = 4096,...}) = 0

Open ("/home/www/wms2.xxx.com/yii/web/CHttpCookie.php", O_RDONLY) = 5

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2772,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2772,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2772,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2772,...}) = 0

Mmap (NULL, 2772, PROT_READ, MAP_SHARED, 5, 0) = 0x7fd9b4804000

Munmap (0x7fd9b4804000, 2772) = 0

Close (5) = 0

Stat ("/home/www/wms2.xxx.com/protected/extensions/redis/XMRedis.php", {st_mode = S_IFREG | 0777, st_size = 2672,...}) = 0

Lstat ("/home/www/wms2.xxx.com/protected/extensions/redis/XMRedis.php", {st_mode = S_IFREG | 0777, st_size = 2672,...}) = 0

Lstat ("/home/www/wms2.xxx.com/protected/extensions/redis", {st_mode = S_IFDIR | 0777, st_size = 4096,...}) = 0

Lstat ("/home/www/wms2.xxx.com/protected/extensions", {st_mode = S_IFDIR | 0777, st_size = 4096,...}) = 0

Open ("/home/www/wms2.xxx.com/protected/extensions/redis/XMRedis.php", O_RDONLY) = 5

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2672,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2672,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2672,...}) = 0

Fstat (5, {st_mode = S_IFREG | 0777, st_size = 2672,...}) = 0

Mmap (NULL, 2672, PROT_READ, MAP_SHARED, 5, 0) = 0x7fd9b4804000

Munmap (0x7fd9b4804000, 2672) = 0

Close (5) = 0

Socket (PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 5

Close (5) = 0

Socket (PF_INET, SOCK_STREAM, IPPROTO_IP) = 5

Fcntl (5, F_GETFL) = 0x2 (flags O_RDWR)

Fcntl (5, F_SETFL, O_RDWR | O_NONBLOCK) = 0

Connect (5, {sa_family = AF_INET, sin_port = htons (22122), sin_addr = inet_addr ("10.237.36.231")}, 16) =-1 EINPROGRESS (Operation now in progress)

Poll ([{fd = 5, events = POLLIN | POLLOUT | POLLERR | POLLHUP}], 1, 3000) = 1 ([{fd = 5, revents = POLLOUT}])

Getsockopt (5, SOL_SOCKET, SO_ERROR, [0], [4]) = 0

Fcntl (5, F_SETFL, O_RDWR) = 0

Setsockopt (5, SOL_TCP, TCP_NODELAY, [1], 4) = 0

Poll ([{fd = 5, events = POLLIN | POLLPRI | POLLERR | POLLHUP}], 1, 0) = 0 (Timeout)

Sendto (5, "* 2 \ r \ n $4 \ r \ nAUTH \ r \ n $9 \ r \ nxm_wms_rs \ r \ n", 29, MSG_DONTWAIT, NULL, 0) = 29

Poll ([{fd = 5, events = POLLIN | POLLPRI | POLLERR | POLLHUP}], 1, 0) = 0 (Timeout)

Poll ([{fd = 5, events = POLLIN | POLLERR | POLLHUP}], 1, 3000) = 1 ([{fd = 5, revents = POLLIN}])

Recvfrom (5, "+ OK \ r \ n", 8192, MSG_DONTWAIT, NULL, NULL) = 5

--- SIGSEGV (Segmentation fault) @ 0 (0 )---

Process 6011 detached


As you can see, after running XMRedis, process 6011 will die. You can basically find that a problem occurs in php-redis.

Further tracing eventually found some code problems


Public function conn (){

Try {

$ This-> _ redis-> pconnect ($ this-> host, $ this-> port, $ this-> timeout );

// Set client option. must AFTER connected

// Var_dump (Redis: OPT_SERIALIZER, Redis: SERIALIZER_PHP); exit ();

$ This-> _ redis-> setOption (Redis: OPT_SERIALIZER, Redis: SERIALIZER_PHP );

// $ This-> _ redis-> setOption (0, 0 );

$ This-> _ redis-> auth ("xm_wms_rs ");


$ This-> connected = true;


} Catch (RedisException $ e ){

Throw new CHttpException (500, "Redis occurs an error:". $ e-> getMessage ());

}

}

When the code in red is used, the error 502 will be reported, and the Green code is correct.


SetOption: Is this a magic horse? Check the php-redis api


$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);   // don't Serialize data does not serialize data

$ Redis-> setOption (Redis: OPT_SERIALIZER, Redis: SERIALIZER_PHP); // use built-in serialize/unserialize with php built-in serialization

$ Redis-> setOption (Redis: OPT_SERIALIZER, Redis: SERIALIZER_IGBINARY); // use igBinary serialize/unserialize to extend IGBINARY serialization

$ Redis-> setOption (Redis: OPT_PREFIX, 'myappname: '); // use custom prefix on all keys redis key prefix


$ Redis-> setOption (Redis: OPT_SERIALIZER, Redis: SERIALIZER_PHP); if so, 502 is reported.


Why does php built-in serialization cause errors? What happened?

Later, the IGBINARY extension was installed. Finally, install php-redis with the latest version 2.24 and run it again.


2.24 php-redis source code address https://github.com/nicolasff/phpredis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.