Skip to content

Connection to PGPool-II Fails to return results #513

@mbell8903

Description

@mbell8903

So I ran into an issue that I'm not totally sure how to fix. We are using PGPool-II to do all of our communication to the DB since we have a handful of services connecting. That being said I know pg has connection pooling built in by default, but our configurations demand that all services go through PGPool-II. Anyways the issue I'm seeing is that if I connect to the postgres instance directly, everything works well, but if i attempt to connect thought PGPool-II the callback in client.query never gets called. Here is my code:

 getKeyData : function (key, cb) {
                pg.connect(config.connectionInfo.db.connectionString, function(err, client, done) {
                        if (err) {
                                done();
                                console.error('Failed to fetch client from PostgreSQL connection pool'.red, err);
                                return cb("Failed to fetch client from postgreSQL connection pool");
                        } else {
                                var sql = "SELECT key FROM y WHERE LOWER(key) = LOWER($1) LIMIT 1",
                                        params = [key];

                                if (config.connectionInfo.debug) {
                                        console.log(util.inspect({ query: sql, params: params }, { colors: true }));
                                }

                                client.query(sql, params, function (err, results) {
                                        done();
                                        if (err) {
                                                console.error('Failed to execute query "'.red + colors.green(sql) + '"'.red, err);
                                                return cb('Failed to execute query: ' + err);
                                        } else {
                                                if (results.rows.length > 0) {
                                                        return cb(null, results.rows[0].key);
                                                } else {
                                                        return cb();
                                                }
                                        }
                                });
                        }
                });
        }

Connection string: 'pg://username:pass@localhost:9999/db'

I looked at the PGPool-II logs and have the following:

2014-01-24 15:55:17 DEBUG: pid 28012: I am 28012 accept fd 5
2014-01-24 15:55:17 LOG: pid 28012: connection received: host=127.0.0.1 port=37038
2014-01-24 15:55:17 DEBUG: pid 28012: Protocol Major: 3 Minor: 0 database: ******* user: *******
2014-01-24 15:55:17 DEBUG: pid 28012: do_child: connection exists but startup packet length is not identical
2014-01-24 15:55:17 DEBUG: pid 28012: new_connection: connecting 0 backend
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length: slot: 0 length: 12
2014-01-24 15:55:17 DEBUG: pid 28012: pool_do_auth: auth kind:5
2014-01-24 15:55:17 DEBUG: pid 28012: trying md5 authentication
2014-01-24 15:55:17 DEBUG: pid 28012: DB node id: 0 salt: 91a28b4c
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 28
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: client_encoding value: 'utf-8'
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 23
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: DateStyle value: ISO, MDY
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 25
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: integer_datetimes value: on
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 27
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: IntervalStyle value: postgres
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 21
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: is_superuser value: off
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 25
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: server_encoding value: UTF8
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 26
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: server_version value: 8.4.13
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 33
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: session_authorization value: *******
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 36
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: standard_conforming_strings value: off
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length2: master slot: 0 length: 17
2014-01-24 15:55:17 DEBUG: pid 28012: 0 th backend: name: TimeZone value: UTC
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length: slot: 0 length: 12
2014-01-24 15:55:17 DEBUG: pid 28012: pool_do_auth: cp->info[i]:0x2ad60b540000 pid:17747
2014-01-24 15:55:17 DEBUG: pid 28012: pool_send_auth_ok: send pid 17747 to frontend
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_command_success: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_writing_transaction: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_failed_transaction: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_transaction_isolation: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_skip_reading_from_backends: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_ignore_till_sync: done
2014-01-24 15:55:17 DEBUG: pid 28012: read_kind_from_backend: read kind from 0 th backend Z NUM_BACKENDS: 1
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessBackendResponse: kind from backend: Z
2014-01-24 15:55:17 DEBUG: pid 28012: pool_read_message_length: slot: 0 length: 5
2014-01-24 15:55:17 DEBUG: pid 28012: ReadyForQuery: transaction state:
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessFrontendResponse: kind from frontend P(50)
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: Parse: statement name <>
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_query_in_progress: done
2014-01-24 15:55:17 LOG: pid 28012: DB node id: 0 backend pid: 17747 statement: Parse: SELECT key FROM y WHERE LOWER(key) = LOWER($1) LIMIT 1
2014-01-24 15:55:17 DEBUG: pid 28012: wait_for_query_response: waiting for backend 0 completing the query
2014-01-24 15:55:17 DEBUG: pid 28012: read_kind_from_backend: read kind from 0 th backend 1 NUM_BACKENDS: 1
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessBackendResponse: kind from backend: 1
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_command_success: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessFrontendResponse: kind from frontend B(42)
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: Bind: waiting for master completing the query
2014-01-24 15:55:17 LOG: pid 28012: DB node id: 0 backend pid: 17747 statement: B message
2014-01-24 15:55:17 DEBUG: pid 28012: wait_for_query_response: waiting for backend 0 completing the query
2014-01-24 15:55:17 DEBUG: pid 28012: read_kind_from_backend: read kind from 0 th backend 2 NUM_BACKENDS: 1
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessBackendResponse: kind from backend: 2
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_command_success: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessFrontendResponse: kind from frontend D(44)
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: Describe: waiting for master completing the query
2014-01-24 15:55:17 LOG: pid 28012: DB node id: 0 backend pid: 17747 statement: D message
2014-01-24 15:55:17 DEBUG: pid 28012: wait_for_query_response: waiting for backend 0 completing the query
2014-01-24 15:55:17 DEBUG: pid 28012: read_kind_from_backend: read kind from 0 th backend T NUM_BACKENDS: 1
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessBackendResponse: kind from backend: T
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessFrontendResponse: kind from frontend E(45)
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_doing_extended_query_message: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: Execute: portal name <>
2014-01-24 15:55:17 DEBUG: pid 28012: Execute: query: SELECT key FROM y WHERE LOWER(key) = LOWER($1) LIMIT 1
2014-01-24 15:55:17 LOG: pid 28012: DB node id: 0 backend pid: 17747 statement: Execute: SELECT key FROM y WHERE LOWER(key) = LOWER($1) LIMIT 1
2014-01-24 15:55:17 DEBUG: pid 28012: wait_for_query_response: waiting for backend 0 completing the query
2014-01-24 15:55:17 DEBUG: pid 28012: read_kind_from_backend: read kind from 0 th backend D NUM_BACKENDS: 1
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessBackendResponse: kind from backend: D
2014-01-24 15:55:17 DEBUG: pid 28012: read_kind_from_backend: read kind from 0 th backend C NUM_BACKENDS: 1
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessBackendResponse: kind from backend: C
2014-01-24 15:55:17 DEBUG: pid 28012: pool_set_command_success: done
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_query_in_progress: done
2014-01-24 15:55:17 DEBUG: pid 28012: ProcessFrontendResponse: kind from frontend H(48)
2014-01-24 15:55:17 DEBUG: pid 28012: pool_unset_doing_extended_query_message: done'

As you can see its executing the query and processing the response from the backend. Also all of the other python based services i have running around seem to use PGPool-II just fine.

Any ideas as to why this would be happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions