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-23.2: server: option to wait for default_target_cluster on connect #113933

Merged
merged 6 commits into from
Nov 9, 2023

Conversation

blathers-crl[bot]
Copy link

@blathers-crl blathers-crl bot commented Nov 7, 2023

Backport 6/6 commits from #113687 on behalf of @stevendanna.

/cc @cockroachdb/release


Virtual cluster startup is asynchronous. As a result, it can be hard to
orchestrate bringing a virtual cluster up since the client needs to
retry until the cluster is available.

This makes it a little easier by optionally allowing connections to
the default_target_cluster to be held until the cluster is online.

As a result, a user who does:

ALTER VIRTUAL CLUSTER app START SERVICE SHARED
SET CLUSTER SETTING server.controller.default_target_cluster = 'app'

Should be able to immediately connect to the same node without having
to handle retries while the virtual cluster starts up.

Note that we can extend this to wait for any
tenant. The restriction on only waiting on the default_target_cluster
is that we need to thread a little state into the server controller in
order to avoid pitfalls such as holding a lot of connections open for
longer than needed for a tenant that will never become available
because it doesn't exist.

In a future PR, we will set this option by default in the replication-source and replication-target
configuration profiles.

Built on #113666

Informs #111637

Release note: None


Release justification: Usability fix for physical replication, making orchestration mistakes less likely.

Virtual cluster startup is asynchronous. As a result, it can be hard to
orchestrate bringing a virtual cluster up since the client needs to
retry until the cluster is available.

This makes it a little easier by optionally allowing connections to
the default_target_cluster to be held until the cluster is online.

As a result, a user who does:

    ALTER VIRTUAL CLUSTER app START SERVICE SHARED
    SET CLUSTER SETTING server.controller.default_target_cluster = 'app'

Should be able to immediately connect to the same node without having
to handle retries while the virtual cluster starts up.

Note that in future PRs we can extend this to wait for _any_
tenant. The restriction on only waiting on the default_target_cluster
is that we need to thread a little state into the server controller in
order to avoid pitfalls such as holding a lot of connections open for
longer than needed for a tenant that will never become available
because it doesn't exist.

Informs #111637

Release note: None
Using singleflight avoids having a large number of connections polling
for the tenant to start up.

Release note: none
Rather than polling, this uses a channel to notify us when the set of
tenants has changed or when the tenant's state has changed.

Release note: None
We call getServer on every new connection. It seem prudent that we
wouldn't want concurrent connections to contend over a mutex when most
of the time nothing is writing to the data protected by this mutex.

Release note: None
We can use a zero-wait time to indicate no waiting, saving a cluster
setting.

Epic: none

Release note: None
@blathers-crl blathers-crl bot requested a review from a team as a code owner November 7, 2023 14:32
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-23.2-113687 branch from a0aaca0 to aeffaed Compare November 7, 2023 14:32
@blathers-crl blathers-crl bot requested review from a team as code owners November 7, 2023 14:32
@blathers-crl blathers-crl bot requested a review from a team November 7, 2023 14:32
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-23.2-113687 branch from aeffaed to ba28b36 Compare November 7, 2023 14:32
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Nov 7, 2023
@blathers-crl blathers-crl bot requested review from abarganier and removed request for a team November 7, 2023 14:32
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-23.2-113687 branch from 7261c15 to cb7634f Compare November 7, 2023 14:32
Copy link
Author

blathers-crl bot commented Nov 7, 2023

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Backports should only be created for serious
    issues
    or test-only changes.
  • Backports should not break backwards-compatibility.
  • Backports should change as little code as possible.
  • Backports should not change on-disk formats or node communication protocols.
  • Backports should not add new functionality (except as defined
    here).
  • Backports must not add, edit, or otherwise modify cluster versions; or add version gates.
  • All backports must be reviewed by the owning areas TL and one additional
    TL. For more information as to how that review should be conducted, please consult the backport
    policy
    .
If your backport adds new functionality, please ensure that the following additional criteria are satisfied:
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters. State changes must be further protected such that nodes running old binaries will not be negatively impacted by the new state (with a mixed version test added).
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.
  • Your backport must be accompanied by a post to the appropriate Slack
    channel (#db-backports-point-releases or #db-backports-XX-X-release) for awareness and discussion.

Also, please add a brief release justification to the body of your PR to justify this
backport.

@blathers-crl blathers-crl bot added the backport Label PR's that are backports to older release branches label Nov 7, 2023
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@stevendanna
Copy link
Collaborator

This does add new functionality. But:

  • The functionality should only impact users of shared-process multi-tenancy who have set: server.controller.default_target_cluster.
  • There is a clear early-exit for the system tenant so this should not inadvertently affect existing single-tenant deployments:

https://github.com/cockroachdb/cockroach/pull/113933/files#diff-5012b40344254902c8506a506c562ae80ed3c1b5a8e033745297a5ba0497d06dR95-R99

It is likely not the minimal change; however, I'm wary of having different versions of this on master vs 23.2. If we are unhappy with the size of this change, I recommend we simply forgo the backport and live with the orchestration problem.

@stevendanna stevendanna merged commit e066b73 into release-23.2 Nov 9, 2023
2 checks passed
@stevendanna stevendanna deleted the blathers/backport-release-23.2-113687 branch November 9, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants