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

Tag reading when the database does not exist #25

Open
pavel-krivanek opened this issue Apr 20, 2020 · 8 comments
Open

Tag reading when the database does not exist #25

pavel-krivanek opened this issue Apr 20, 2020 · 8 comments

Comments

@pavel-krivanek
Copy link
Contributor

When the database you try to connect does not exist, the method
P3MessageBuffer>>#readFrom: (called from P3Client>>#readMessageOnError:)
fails because the readStream next returns nil and the internal error handling does not expect such case.

@svenvc
Copy link
Owner

svenvc commented Apr 20, 2020

I get a clean error, instance of P3Error with message

P3Error PostgreSQL database "foo" does not exist

when I try to connect to a non existing DB

P3Client url: 'psql://sven@localhost/foo'

and then do #isWorking

@pavel-krivanek
Copy link
Contributor Author

I got this error while connecting using Glorp via P3DatabaseDriver. The password is set to nil which may be part of the problem.
Then the issue raises from: P3Client>>#runAuthentication, specifically from self readMessageCloseAfterError tag. The socket is closed.

@pavel-krivanek
Copy link
Contributor Author

So the nil password is not really an issue, it is set correctly. I was just confused by the fact that Glorp deletes the password from the Login instance after the first usage (and it does not use discardPassword message for it)

@pavel-krivanek
Copy link
Contributor Author

to reproduce in my setup, I just need to do

        connection := P3Client new.
	connection 
		host: 'localhost';
		port: 5433;
		database: 'pdmCC';
		user: 'pdm';
		password: 'somePassword'.
	connection connect

Where everything except the database name is correct.

@pavel-krivanek
Copy link
Contributor Author

It is PostgreSQL 12

@svenvc
Copy link
Owner

svenvc commented Apr 20, 2020

I was on 11.6, now also on 12.1

P3Client new 
		host: 'localhost';
		port: 5432;
		database: 'pdmCC';
		user: 'sven';
		"password: '';"
		connect.

still gives me a clean P3Error.

Note that #readMessageCloseAfterError does a #close hence the connection will be nil (after the info is read - the dictionary is filled in correctly).

I am using https://postgresapp.com on macOS, Pharo 7.0.1 FWIW

@pavel-krivanek
Copy link
Contributor Author

We are on Pharo 9.0 and Windows...

@svenvc
Copy link
Owner

svenvc commented May 19, 2020

This sometimes happens in regular use as well.

It seems that at that point the underlying socket stream is in the state 'otherEndClosedButNotThisEnd'.

It remains hard to reproduce though.

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