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

release-2.1: sql,pgwire: fix a host of pgwire/sql interaction bugs + perf fixes #31021

Merged
merged 8 commits into from
Oct 7, 2018

Conversation

knz
Copy link
Contributor

@knz knz commented Oct 5, 2018

Backport:

Please see individual PRs for details.

/cc @cockroachdb/release

nvanbenschoten and others added 8 commits October 5, 2018 21:09
... and comments around the SessionRegistry.

Release note: None
Before this patch, `cancel session <foo>` would cause a connExecutor's
context to be canceled. This patch switches it to cancel the pgwire
connection's ctx instead (which was a parent of the connExecutor's ctx;
now the two are the same), as nature intended. For example, reading from
the network connection should stop ASAP after `cancel session`. It also
opens to door to guaranteeing that the client using the respective
session is unblocked in a timely manner (by the server closing the
network connection), although that is not currently implemented (pgwire
will still wait for the connExecutor to react to cancelation and finish
its task before closing the net.Conn).
This patch also eliminates what I presume to have been a crash when
someone tries to cancel a "session" created by the InternalExecutor. It
will now be a no-op.
This patch also moves a cancelation callback out of
connExecutor.ctxHolder. I'm trying to get rid of that guy, which is how
this patch came to be.

I've also added a TODO with some thoughts on a better design for session
cancelation, originally expressed in
cockroachdb#23861 (comment).
FWIW, I've tried to be the change, but gave up for the moment.

Release note: None
Release note (bug fix): CockroachDB now properly ignores
non-alphanumeric characters in encoding names passed to
`convert_from()`, `client_encoding`, etc., for compatibility with
PostgreSQL.
Prior to this patch, CockroachDB:

- incorrectly ignored the `extra_float_digits` client
  parameter.
- improperly reported `ISO` as default value for server
  status parameter and session var `DateStyle` (the pg
  default is `ISO, MDY`.
- failed to report `TimeZone`, `is_superuser` and
  `session_authorization` in the server status parameters.
- failed to report the correct (and client-provided) value of
  `application_name` in the server status parameters.
- did not report the correct defaults in `pg_catalog.pg_settings`.

This patch corrects these various bugs by:

- keeping the client-provided parameters as session defaults, to be
  picked up by RESET and pg_settings. (Prior to this patch, the
  client parameters were discarded after setting up the session
  initially.)
- extending the handling of session variables to support reporting
  their current value during connection intiialization. This way
  the server status parameter can report the session variables
  that were just initialized from the client-provided defaults.
- eliminating the ad-hoc constant list of "statusServerParams"
  maintained in pgwire/conn.go, which could dangerously go out of sync
  with the session variable defaults without anyone noticing.
- adding the missing reports for `is_superuser` and
  `session_authorization`.

Because CockroachDB now properly honors the value of
extra_float_digits provided by the client, any test that uses lib/pq
must now account for the fact that lib/pq automatically sets this
parameter to 2. The logic_test code is modified accordingly.

Because CockroachDB now properly reports the current TimeZone
parameter to the client during connection initialization, any test
that uses lib/pq must now account for the fact that lib/pq will load
that zone name into any parsed timestamp value coming from the
server. The tests that print out timestamps have been modified
accordingly.

As a side effect of this fix, it is now possible to set arbitrary
session variables in the client connection URL. This has another
benefit reported in the release notes below.

Release note (bug fix): CockroachDB now properly recognizes the value
of `extra_float_digits` provided by clients as a connection parameter.

Release note (bug fix): CockroachDB now properly recognizes two-part
values for the session variable and connection parameter `DateStyle`,
for compatibility with PostgreSQL.

Release note (bug fix): CockroachDB now reports all server status
parameters supported by PostgreSQL when setting up a session. This is
expected to improve compatibility with some drivers.

Release note (bug fix): CockroachDB now properly uses the
client-provided default values when using the RESET statement (or SET
... = DEFAULT).

Release note (bug fix): CockroachDB now properly fills the columns
`boot_val` and `reset_val` in `pg_catalog.pg_settings` for better
compatibility with PostgreSQL.

Release note (cli change): It is now possible to provide
initial/default values for any customizable session variable in the
client connection URL.

Release note (sql change): CockroachDB now supports more
customizations from PostgreSQL client drivers when initially setting
up the client connection.
@knz knz requested a review from a team as a code owner October 5, 2018 19:11
@knz knz requested review from a team October 5, 2018 19:11
@knz knz requested a review from a team as a code owner October 5, 2018 19:11
@knz knz requested review from a team October 5, 2018 19:11
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commits I reviewed originally look good!

@knz knz merged commit bcef656 into cockroachdb:release-2.1 Oct 7, 2018
@knz knz deleted the backport2.1-30508-30813-30702 branch October 7, 2018 08:50
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

Successfully merging this pull request may close these issues.

5 participants