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

Intermittent Password Authentication Failure only on Node v6 #1229

Closed
sarus opened this issue Feb 24, 2017 · 2 comments
Closed

Intermittent Password Authentication Failure only on Node v6 #1229

sarus opened this issue Feb 24, 2017 · 2 comments

Comments

@sarus
Copy link

sarus commented Feb 24, 2017

When running the following versions:

Node v6.9.4
Postgres v9.5.5
node-postgres v6.1.2
CentOS 7.1.1503

We intermittently get the following error when attempting to connect to the database:

{
	"code": "ERR_DB_CONNECTION_FAILURE",
	"more": {
		"name": "error",
		"length": 93,
		"severity": "FATAL",
		"code": "28P01",
		"file": "auth.c",
		"line": "285",
		"routine": "auth_failed"
	}
}

This suggests that the password is incorrect but we haven't changed it. I can run the same query from pgadmin logged in as the same user without any issue. We are printing out the password being used for the connection and it is correct. If we run the query over and over it will sometimes work and sometimes fail (doesn't seem to be any rhyme or reason as to when it works versus when it fails. It probably only works 1 out of every 10 tries.

Here is how the query is being run:

pg.connect(this.connectionOptions, function(err, client, done){
        if(err){
            // this is where the failure happens so the query isn't even attempted
            done();
            connectionErrorCb(new ApiError(httpCodes.SERVER_ERROR, errorCode, {code:DBG_ERR.DB_CONN_FAILURE, more: err}));
            return;
        }

        client.query(query, function(err, result){
            done();

            if(err){
                var code = DBG_ERR.QUERY_FAILURE;
                if(err.detail){
                    code = err.detail;
                }
                err = new ApiError(httpCodes.SERVER_ERROR, errorCode, {code: code, message: err.message, err: err});
            }

            successCb(err, result);
        });
    });

If we roll back Node to v4.6.1 then the problem goes away. This issue seems related to #1000 and #1018 which are supposedly fixed but it seems like there is still a way the issue can crop up.

This is a really big problem for our software so I'm happy to assist with additional debugging information to help track the problem down.

Thanks!

@vitaly-t
Copy link
Contributor

Is your connection parameter a connection object or a connection string? There was a bug introduced in 6.x version for connection strings at some point.

@sarus
Copy link
Author

sarus commented Feb 24, 2017

@vitaly-t Thanks for the response. Turns out this was user error. The bug I was having was the same bug in #1000 and #1018 but I wasn't actually running node-postgres 6.9.1. My main module was dependent on another module that was actually running the query and it was using an older version of pg. After updating that submodule the issue is resolved.

Sorry for the unwarranted issue!

@sarus sarus closed this as completed Feb 24, 2017
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