10000 concurrency problems with fpm · Issue #399 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content

concurrency problems with fpm #399

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

Closed
edlerd opened this issue Oct 30, 2013 · 1 comment
Closed

concurrency problems with fpm #399

edlerd opened this issue Oct 30, 2013 · 1 comment

Comments

@edlerd
Copy link
edlerd commented Oct 30, 2013

We are using phpredis on a high traffic site. Recently changing to php-fpm and since we are having occasional segfaults.

From our research we suggest it is a concurrency problem due to wrong separation of persistent connection.

Here is an excerpt of a gdb stacktrace from on of the core dumps:

(gdb) bt
#0  0x000000000065c75d in _php_stream_write (stream=0x23856a0, 
    buf=0x2154778 "*2\r\n$3\r\nTTL\r\n$48\r\nDataCollect:15930455cf71f0fb5c8c429412949b4f6c0d\r\n", count=68)
    at /build/buildd/php5-5.3.10/main/streams/streams.c:1098
#1  0x00007f37ce048292 in redis_sock_write () from /usr/lib/php5/20090626/redis.so
#2  0x00007f37ce0367b0 in generic_ttl () from /usr/lib/php5/20090626/redis.so

So the problem is in stream.c. The line where the segfault happens is marked:

PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
{
        int ret = PHP_STREAM_OPTION_RETURN_NOTIMPL;

        if (stream->ops->set_option) { // segfault happens here
                ret = stream->ops->set_option(stream, option, value, ptrparam TSRMLS_CC);
        }    

        if (ret == PHP_STREAM_OPTION_RETURN_NOTIMPL) {
                switch(option) {
                        case PHP_STREAM_OPTION_SET_CHUNK_SIZE:
                                ret = stream->chunk_size;
                                stream->chunk_size = value;
                                return ret; 

                        case PHP_STREAM_OPTION_READ_BUFFER:
                                /* try to match the buffer mode as best we can */
                                if (value == PHP_STREAM_BUFFER_NONE) {
                                        stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
                                } else if (stream->flags & PHP_STREAM_FLAG_NO_BUFFER) {
                                        stream->flags ^= PHP_STREAM_FLAG_NO_BUFFER;
                                }    
                                ret = PHP_STREAM_OPTION_RETURN_OK;
                                break;

                        default:
                                ;    
                }    
        }

        return ret; 
}

Of course one solution would be to deactivate persistent connections, but the performace loss is not so nice. Any ideas how to solve it?

@michael-grunder
Copy link
Member

Closing via #415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0