Skip to content

cli,server: initial cluster configuration via job injection#98380

Closed
knz wants to merge 1 commit intocockroachdb:masterfrom
knz:20230310-init-profiles
Closed

cli,server: initial cluster configuration via job injection#98380
knz wants to merge 1 commit intocockroachdb:masterfrom
knz:20230310-init-profiles

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Mar 10, 2023

Informs #94856.

This change introduces two new mechanisms:

  • a new way to inject SQL statements upon initialization of the SQL layer, with exactly-once semantics. The TLDR is that the SQL server initialization code obtains an "injected SQL" payload from its configuration and synthetizes a one-off job to execute that payload.

    Because the payload is executed as a job, it will execute exactly once and will be guaranteed to execute even if the server that created the job terminates before the job starts or completes. (Another server will pick it up.)

    This mechanism is intended for use both by secondary tenants and the system tenant.

  • a "config profiles" mechanism for the system tenant's SQL service, whereby either a command-line flag (--init-profile) or an env var (COCKROACH_INIT_PROFILE) can be used to choose a pre-defined "injected SQL" payload to populate in the server configuration.

    This leverages the mechanism defined above.

Implementation detail: all job entries created by this mechanism have the job columncreated_by_name set to injected. The unicity of the job entry is enforced using unique values for the column created_by_id.

Release note: None

This change introduces two new mechanisms:

- a new way to inject SQL statements upon initialization of the SQL
  layer, with exactly-once semantics. The TLDR is that the SQL
  server initialization code obtains an "injected SQL" payload from
  its configuration and synthetizes a one-off job to execute that
  payload.

  Because the payload is executed as a job, it will execute exactly
  once and will be guaranteed to execute even if the server that
  created the job terminates before the job starts or
  completes. (Another server will pick it up.)

  This mechanism is intended for use both by secondary tenants
  and the system tenant.

- a "config profiles" mechanism for the system tenant's SQL service,
  whereby either a command-line flag (`--init-profile`) or an env
  var (`COCKROACH_INIT_PROFILE`) can be used to choose a pre-defined
  "injected SQL" payload to populate in the server configuration.

  This leverages the mechanism defined above.

Implementation detail: all job entries created by this mechanism have
the job column`created_by_name` set to `injected`. The unicity of the
job entry is enforced using unique values for the column
`created_by_id`.

Release note: None
@cockroach-teamcity
Copy link
Copy Markdown
Member

cockroach-teamcity commented Mar 10, 2023

This change is Reviewable

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Mar 12, 2023

superseded by #98466.

@knz knz closed this Mar 12, 2023
craig bot pushed a commit that referenced this pull request Apr 20, 2023
98466: cli,server: static configuration profiles r=stevendanna a=knz

Epic: CRDB-23559
Informs #98431. 
Fixes #94856.
(Based off #98459)
Supersedes #98380.

This change introduces a mechanism through which an operator can
select a "configuration profile" via the command-line flag
`--config-profile` or env var `COCKROACH_CONFIG_PROFILE`. The SQL
initialization defined by the profile is applied during server
start-up.

The profiles are (currently) hardcoded inside CockroachDB.

The following profiles are predefined:

- `default`: no configuration.

- `multitenant+noapp`: no pre-defined `application` tenant, but with a
  predefined application tenant template that is used whenever a new
  tenant is defined. This config profile is meant for use for C2C
  replication target clusters.

- `multitenant+app+sharedservice`: shared-process multitenancy with
  pre-defined `application` tenant, based off the same configuration as
  `multitenant+noapp`.

Release note: None

101907: multitenant: misc fixes related to tenant capabilities r=arulajmani a=knz

See individual commits for details.

The last commit in particular probably addresses #99087.

Epic: CRDB-23559

101935: sql: add issue number to todo r=rharding6373 a=rharding6373

Epic: none
Informs: #101934

Release note: none

Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
Co-authored-by: rharding6373 <rharding6373@users.noreply.github.com>
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.

2 participants