Skip to content
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

this module will block nginx main cycle(block other requests) #50

Open
idning opened this issue Mar 29, 2013 · 0 comments
Open

this module will block nginx main cycle(block other requests) #50

idning opened this issue Mar 29, 2013 · 0 comments

Comments

@idning
Copy link

idning commented Mar 29, 2013

hi,

ngx module code ::

/* Fetch the chunk from mongo */
do {
    e = FALSE;
    cursors[i] = gridfile_get_chunks(&gfile, i, 1);
    if (!(cursors[i] && mongo_cursor_next(cursors[i]) == MONGO_OK)) {
        e = TRUE; ecounter++;
        if (ecounter > MONGO_MAX_RETRIES_PER_REQUEST 
            || ngx_http_mongo_reconnect(request->connection->log, mongo_conn) == NGX_ERROR
            || ngx_http_mongo_reauth(request->connection->log, mongo_conn) == NGX_ERROR) {
            ngx_log_error(NGX_LOG_ERR, request->connection->log, 0,
                          "Mongo connection dropped, could not reconnect");
            if(&mongo_conn->conn.connected) { mongo_disconnect(&mongo_conn->conn); }
            gridfile_destroy(&gfile);
            gridfs_destroy(&gfs);
            return NGX_HTTP_SERVICE_UNAVAILABLE;
        }
    }
} while (e);

this will call mongo_cursor_get_more::

static int mongo_cursor_get_more( mongo_cursor *cursor ) {
    int res;
    ...
    mm = mongo_message_create( 16 /*header*/
                               +4 /*ZERO*/
                               +sl
                               +4 /*numToReturn*/
                               +8 /*cursorID*/
                               , 0, 0, MONGO_OP_GET_MORE );



    res = mongo_message_send( cursor->conn, mm );
    res = mongo_read_response( cursor->conn, &( cursor->reply ) );
}

static int mongo_read_response( mongo *conn, mongo_reply **reply ) {

    mongo_env_read_socket( conn, &head, sizeof( head ) );
    //which will do a blocking read.
    ...
}    

the blocking read will block nginx worker, other request will be blocked.

have you make any benchmark on this module?

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

1 participant