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

CockroachDB doesn't return ErrorResponse if client sends a startup message with invalid database name #109992

Closed
giangpham712 opened this issue Sep 4, 2023 · 8 comments
Labels
A-tools-efcore C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@giangpham712
Copy link

giangpham712 commented Sep 4, 2023

Describe the problem
With PosgreSQL, when client sends a startup message with invalid database name, the response will be ErrorResponse as specified here (https://www.postgresql.org/docs/current/protocol-flow.html). CockroachDB still returns a ReadyForQuery response

Additional context
This affects efcore.pg tests

@fqazi

Jira issue: CRDB-31206

@giangpham712 giangpham712 added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Sep 4, 2023
@blathers-crl
Copy link

blathers-crl bot commented Sep 4, 2023

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner labels Sep 4, 2023
@rafiss rafiss added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Sep 5, 2023
@fqazi fqazi added A-tools-efcore T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Sep 5, 2023
@rafiss rafiss removed the X-blathers-untriaged blathers was unable to find an owner label Sep 5, 2023
@fqazi fqazi self-assigned this Sep 5, 2023
@rafiss
Copy link
Collaborator

rafiss commented Sep 5, 2023

Let's add a test for this in pkg/sql/pgwire/testdata/pgtest - let me know if you need help with the syntax for these tests.

@fqazi
Copy link
Collaborator

fqazi commented Sep 8, 2023

@giangpham712 I see the correct behaviour if the start-up message has a bad database name:

Wraps: (2) waiting for *pgproto3.ReadyForQuery, got &pgproto3.ErrorResponse{Severity:"ERROR", SeverityUnlocalized:"ERROR", Code:"3D000", Message:"database \"fake\" does not exist", Detail:"", Hint:"", Position:0, InternalPosition:0, InternalQuery:"", Where:"", SchemaName:"", TableName:"", ColumnName:"", DataTypeName:"", ConstraintName:"", File:"errors.go", Line:148, Routine:"NewUndefinedDatabaseError", UnknownFields:map[uint8]string(nil)}

Are you relying on the implicit database name behaviour from: https://www.postgresql.org/docs/current/protocol-message-formats.html (see Startup Message)

giangpham712 added a commit to jlinder/efcore.pg that referenced this issue Oct 4, 2023
Workaround for CockroachDB issue that doesn't return error when database name is invalid cockroachdb/cockroach#109992
giangpham712 added a commit to jlinder/efcore.pg that referenced this issue Oct 5, 2023
Workaround for CockroachDB issue that doesn't return error when database name is invalid cockroachdb/cockroach#109992
@fqazi
Copy link
Collaborator

fqazi commented Oct 17, 2023

@giangpham712 Can you share the connection string for when this happens? Trying to figure out where things are going off the rails

@giangpham712
Copy link
Author

@fqazi It could be something like this

Host=localhost;Username=crdb_tests;Port=26257;Include Error Detail=True;Timeout=300;Command Timeout=300;Options="-c null_ordered_last=true";Database=BatchingTest;Pooling=False;Multiplexing=False

@rafiss
Copy link
Collaborator

rafiss commented Oct 17, 2023

@fqazi maybe this related to mixed-case names specifically?

giangpham712 added a commit to jlinder/efcore.pg that referenced this issue Oct 23, 2023
Workaround for CockroachDB issue that doesn't return error when database name is invalid cockroachdb/cockroach#109992
@fqazi
Copy link
Collaborator

fqazi commented Dec 5, 2023

No, case sensitivity also works fine if I try this in the pg_wire tests for CRDB. Let me try using Npgsql and seeing if that exhibits this problem

@fqazi
Copy link
Collaborator

fqazi commented Dec 5, 2023

@giangpham712 I tried the following sequence and still see the correct error in .NET (i.e. invalid database names error out correctly):

var connString = "Host=localhost;Username=root;Port=26257;Database=Defaultdb";
await using var conn = new NpgsqlConnection(connString);
await conn.OpenAsync();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tools-efcore C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
No open projects
Status: Triage
Development

No branches or pull requests

3 participants