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: server/ui: fix crash caused by race in server initialization #30838

Merged
merged 3 commits into from
Oct 1, 2018

Conversation

vilterp
Copy link
Contributor

@vilterp vilterp commented Oct 1, 2018

Backport 3/3 commits from #30746.

/cc @cockroachdb/release


Fixes #25771

See commits for details.

Pete Vilter and others added 3 commits October 1, 2018 12:37
HTTP requests are passed through an authentication mux, which checks
that the user is authenticated based on the cookies on the request. To
check authentication, the mux runs SQL to look up a session in the
system.web_sessions table.

Prior to this change, it was possible to hit the cluster with an HTTP
request which would cause the SQL to be run, before the SQL system was
fully initialized -- specifically before the cluster version setting was
initialized. This would crash the node.

This change delays installation of the authentication mux until after
the SQL system has been initialized, removing the possibility of this
crash.

Release note: None
Teach the cluster-init test to reproduce the crash during bootup
described in issue cockroachdb#25771. The trick is to send requests with a session
cookie, as the admin UI would, while the cluster is waiting for init.

Note that the crash was caused by the authenticationMux, which is used
to protect secure clusters, but this test uses an insecure cluster. This
is relying on a wart: an authenticationMux is installed for UI assets
whether or not the cluster is secure. This could change in the future. A
better test would use a secure cluster, however roachprod/roachtest do
not easily support that at this time, nor is it easy to write a unit
test that exercises the crash more robustly.

Release note: None
Including
- more comments
- rename `maybeAuthMux` to `authenticatedUIHandler`
- move `authHandler` down near where it's initialized

Release note: None
@vilterp vilterp requested review from a team October 1, 2018 16:37
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@vilterp vilterp requested review from benesch and couchand October 1, 2018 16:37
@vilterp vilterp merged commit 04bc187 into cockroachdb:release-2.1 Oct 1, 2018
@vilterp vilterp deleted the backport2.1-30746 branch October 1, 2018 17:16
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.

3 participants