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

kvflowcontrol: add inspectz pages for replication ac v2 #128091

Closed
Tracked by #123509
kvoli opened this issue Aug 1, 2024 · 0 comments · Fixed by #130270
Closed
Tracked by #123509

kvflowcontrol: add inspectz pages for replication ac v2 #128091

kvoli opened this issue Aug 1, 2024 · 0 comments · Fixed by #130270
Assignees
Labels
A-replication-admission-control-v2 Related to introduction of replication AC v2 C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-kv KV Team

Comments

@kvoli
Copy link
Collaborator

kvoli commented Aug 1, 2024

There are existing inspectz structures in place for querying replication admission control. This issue is to extend, or add new structure such that the v2 implementation supports the same functionality.

See https://github.com/sumeerbhola/cockroach/blob/5c2a50ec4d0dcf2502d742ac9036d39995886abc/pkg/kv/kvserver/kvflowcontrol/kvflowinspectpb/kvflowinspect.proto#L21 for v1.

Jira issue: CRDB-40795

Epic CRDB-37515

@kvoli kvoli added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-replication-admission-control-v2 Related to introduction of replication AC v2 labels Aug 1, 2024
@blathers-crl blathers-crl bot added the T-kv KV Team label Aug 1, 2024
@github-project-automation github-project-automation bot moved this to Incoming in KV Aug 28, 2024
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 6, 2024
The `kvflowinspectpb.Stream` represents a replication stream state and
is used in tests and `inspectz` related observability.

`kvflowinspectpb.Stream` used to contain two available token fields,
broken into work class. As rac2 is being added, two additional token
fields are required, accounting for send tokens.

Rename the existing fields with `Eval` added and introduce two more
fields, mirroring the existing ones as `Send`.

Part of: cockroachdb#128091
Release note: None
@kvoli kvoli self-assigned this Sep 6, 2024
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 9, 2024
Implement `Inspect` methods on the `RangeController`, `TokenTracker` and
`StreamTokenCounterProvider`. These methods will be used to power the
`inspectz` endpoint (mostly unused) and `crdb_internal` tables
(primarily testing).

`RangeController.Inspect` returns a `kvflowinspectpb.Handle`, identical
to the `Handle` abstraction in v1, containing all streams and their
token deductions/state.

`TokenTracker.Inspect` returns the tracked deduction.s

`StreamTokenCounterProvider.Inspect` returns the token state of all
streams, where `StreamTokenCounterProvider.InspectStream` returns the
token state of the given stream.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 9, 2024
The previous patch introduced `Inspect` methods mapping to `Handle`,
`ConnectedStream`, `TrackedDeduction` and `Stream`. Extract the
`Inspect` methods into their own interfaces which are implemented by
rac2.

The methods are then hooked into `storesForRAC2`, which can be accessed
in a similar manner to the v1 methods.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 9, 2024
Rename the existing `inspectz/(kvflowhandles|kvflowcontroller)` endpoint
to `inspectz/v1/(kvflowhandles|kvflowcontroller)`, and introduce the v2
endpoint serving the same types,
`inspectz/v2/(kvflowhandles|kvflowcontroller)`.

Note that these endpoints are not used internally in any webpages or
testing and are not relied upon. Internal tables call
`KVFlowHandles(V1)` or `KVFlowController(V1)` directly to populate
themselves.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 9, 2024
The existing flow control tables are:

```
crdb_internal.kv_flow_controller
crdb_internal.kv_flow_control_handles
crdb_internal.kv_flow_token_deductions
```

Which are used in testing to assert on flow control stream state and
transitions.

Introduce another set of three tables, most of which are identical to the
exsting tables but populating the table data using rac2.

```
crdb_internal.kv_flow_controller_v2
crdb_internal.kv_flow_control_handles_v2
crdb_internal.kv_flow_token_deductions_v2
```

`crdb_internal.kv_flow_controller_v2` has two additional columns,
tracking the amount of available (regular|elastic) send tokens. The
schema is:

```
CREATE TABLE crdb_internal.kv_flow_controller_v2 (
  tenant_id                     INT NOT NULL,
  store_id                      INT NOT NULL,
  available_eval_regular_tokens INT NOT NULL,
  available_eval_elastic_tokens INT NOT NULL,
  available_send_regular_tokens INT NOT NULL,
  available_send_elastic_tokens INT NOT NULL
);
```

Note that unless rac2 is enabled, the tables are unlikely to show
anything interesting. Both tables (v1 and v2) are kept for
compatibility, with an intent to replace the v1 tables with the v2 ones
after v1 replication flow control is removed entirely from the code.

Resolves: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The `kvflowinspectpb.Stream` represents a replication stream state and
is used in tests and `inspectz` related observability.

`kvflowinspectpb.Stream` used to contain two available token fields,
broken into work class. As rac2 is being added, two additional token
fields are required, accounting for send tokens.

Rename the existing fields with `Eval` added and introduce two more
fields, mirroring the existing ones as `Send`.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
Implement `Inspect` methods on the `RangeController`, `TokenTracker` and
`StreamTokenCounterProvider`. These methods will be used to power the
`inspectz` endpoint (mostly unused) and `crdb_internal` tables
(primarily testing).

`RangeController.Inspect` returns a `kvflowinspectpb.Handle`, identical
to the `Handle` abstraction in v1, containing all streams and their
token deductions/state.

`TokenTracker.Inspect` returns the tracked deductions.

`StreamTokenCounterProvider.Inspect` returns the token state of all
streams, where `StreamTokenCounterProvider.InspectStream` returns the
token state of the given stream.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The previous patch introduced `Inspect` methods mapping to `Handle`,
`ConnectedStream`, `TrackedDeduction` and `Stream`. Extract the
`Inspect` methods into their own interfaces which are implemented by
rac2.

The methods are then hooked into `storesForRAC2`, which can be accessed
in a similar manner to the v1 methods.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
Rename the existing `inspectz/(kvflowhandles|kvflowcontroller)` endpoint
to `inspectz/v1/(kvflowhandles|kvflowcontroller)`, and introduce the v2
endpoint serving the same types,
`inspectz/v2/(kvflowhandles|kvflowcontroller)`.

Note that these endpoints are not used internally in any webpages or
testing and are not relied upon. Internal tables call
`KVFlowHandles(V1)` or `KVFlowController(V1)` directly to populate
themselves.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The existing flow control tables are:

```
crdb_internal.kv_flow_controller
crdb_internal.kv_flow_control_handles
crdb_internal.kv_flow_token_deductions
```

Which are used in testing to assert on flow control stream state and
transitions.

Introduce another set of three tables, most of which are identical to
the existing tables but populating the table data using rac2.

```
crdb_internal.kv_flow_controller_v2
crdb_internal.kv_flow_control_handles_v2
crdb_internal.kv_flow_token_deductions_v2
```

`crdb_internal.kv_flow_controller_v2` has two additional columns,
tracking the amount of available (regular|elastic) send tokens. The
schema is:

```
CREATE TABLE crdb_internal.kv_flow_controller_v2 (
  tenant_id                     INT NOT NULL,
  store_id                      INT NOT NULL,
  available_eval_regular_tokens INT NOT NULL,
  available_eval_elastic_tokens INT NOT NULL,
  available_send_regular_tokens INT NOT NULL,
  available_send_elastic_tokens INT NOT NULL
);
```

Note that unless rac2 is enabled, the tables are unlikely to show
anything interesting. Both tables (v1 and v2) are kept for
compatibility, with an intent to replace the v1 tables with the v2 ones
after v1 replication flow control is removed entirely from the code.

Resolves: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The previous patch introduced `Inspect` methods mapping to `Handle`,
`ConnectedStream`, `TrackedDeduction` and `Stream`. Extract the
`Inspect` methods into their own interfaces which are implemented by
rac2.

The methods are then hooked into `storesForRAC2`, which can be accessed
in a similar manner to the v1 methods.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
Rename the existing `inspectz/(kvflowhandles|kvflowcontroller)` endpoint
to `inspectz/v1/(kvflowhandles|kvflowcontroller)`, and introduce the v2
endpoint serving the same types,
`inspectz/v2/(kvflowhandles|kvflowcontroller)`.

Note that these endpoints are not used internally in any webpages or
testing and are not relied upon. Internal tables call
`KVFlowHandles(V1)` or `KVFlowController(V1)` directly to populate
themselves.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The existing flow control tables are:

```
crdb_internal.kv_flow_controller
crdb_internal.kv_flow_control_handles
crdb_internal.kv_flow_token_deductions
```

Which are used in testing to assert on flow control stream state and
transitions.

Introduce another set of three tables, most of which are identical to
the existing tables but populating the table data using rac2.

```
crdb_internal.kv_flow_controller_v2
crdb_internal.kv_flow_control_handles_v2
crdb_internal.kv_flow_token_deductions_v2
```

`crdb_internal.kv_flow_controller_v2` has two additional columns,
tracking the amount of available (regular|elastic) send tokens. The
schema is:

```
CREATE TABLE crdb_internal.kv_flow_controller_v2 (
  tenant_id                     INT NOT NULL,
  store_id                      INT NOT NULL,
  available_eval_regular_tokens INT NOT NULL,
  available_eval_elastic_tokens INT NOT NULL,
  available_send_regular_tokens INT NOT NULL,
  available_send_elastic_tokens INT NOT NULL
);
```

Note that unless rac2 is enabled, the tables are unlikely to show
anything interesting. Both tables (v1 and v2) are kept for
compatibility, with an intent to replace the v1 tables with the v2 ones
after v1 replication flow control is removed entirely from the code.

Resolves: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The `kvflowinspectpb.Stream` represents a replication stream state and
is used in tests and `inspectz` related observability.

`kvflowinspectpb.Stream` used to contain two available token fields,
broken into work class. As rac2 is being added, two additional token
fields are required, accounting for send tokens.

Rename the existing fields with `Eval` added and introduce two more
fields, mirroring the existing ones as `Send`.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
Implement `Inspect` methods on the `RangeController`, `TokenTracker` and
`StreamTokenCounterProvider`. These methods will be used to power the
`inspectz` endpoint (mostly unused) and `crdb_internal` tables
(primarily testing).

`RangeController.Inspect` returns a `kvflowinspectpb.Handle`, identical
to the `Handle` abstraction in v1, containing all streams and their
token deductions/state.

`TokenTracker.Inspect` returns the tracked deductions.

`StreamTokenCounterProvider.Inspect` returns the token state of all
streams, where `StreamTokenCounterProvider.InspectStream` returns the
token state of the given stream.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
The previous patch introduced `Inspect` methods mapping to `Handle`,
`ConnectedStream`, `TrackedDeduction` and `Stream`. Extract the
`Inspect` methods into their own interfaces which are implemented by
rac2.

The methods are then hooked into `storesForRAC2`, which can be accessed
in a similar manner to the v1 methods.

Part of: cockroachdb#128091
Release note: None
kvoli added a commit to kvoli/cockroach that referenced this issue Sep 12, 2024
Rename the existing `inspectz/(kvflowhandles|kvflowcontroller)` endpoint
to `inspectz/v1/(kvflowhandles|kvflowcontroller)`, and introduce the v2
endpoint serving the same types,
`inspectz/v2/(kvflowhandles|kvflowcontroller)`.

Note that these endpoints are not used internally in any webpages or
testing and are not relied upon. Internal tables call
`KVFlowHandles(V1)` or `KVFlowController(V1)` directly to populate
themselves.

Part of: cockroachdb#128091
Release note: None
craig bot pushed a commit that referenced this issue Sep 12, 2024
130270: kvserver,inspectz: add rac2 inspectz support  r=sumeerbhola a=kvoli

The existing flow control tables are:

```
crdb_internal.kv_flow_controller
crdb_internal.kv_flow_control_handles
crdb_internal.kv_flow_token_deductions
```

Which are used in testing to assert on flow control stream state and
transitions.

Introduce another set of three tables, most of which are identical to the
exsting tables but populating the table data using rac2.

```
crdb_internal.kv_flow_controller_v2
crdb_internal.kv_flow_control_handles_v2
crdb_internal.kv_flow_token_deductions_v2
```

`crdb_internal.kv_flow_controller_v2` has two additional columns,
tracking the amount of available (regular|elastic) send tokens. The
schema is:

```
CREATE TABLE crdb_internal.kv_flow_controller_v2 (
  tenant_id                     INT NOT NULL,
  store_id                      INT NOT NULL,
  available_eval_regular_tokens INT NOT NULL,
  available_eval_elastic_tokens INT NOT NULL,
  available_send_regular_tokens INT NOT NULL,
  available_send_elastic_tokens INT NOT NULL
);
```

Note that unless rac2 is enabled, the tables are unlikely to show
anything interesting. Both tables (v1 and v2) are kept for
compatibility, with an intent to replace the v1 tables with the v2 ones
after v1 replication flow control is removed entirely from the code.

Resolves: #128091
Release note: None

Co-authored-by: Austen McClernon <[email protected]>
@craig craig bot closed this as completed in c0a5058 Sep 12, 2024
msbutler pushed a commit to msbutler/cockroach that referenced this issue Sep 13, 2024
130270: kvserver,inspectz: add rac2 inspectz support  r=sumeerbhola a=kvoli

The existing flow control tables are:

```
crdb_internal.kv_flow_controller
crdb_internal.kv_flow_control_handles
crdb_internal.kv_flow_token_deductions
```

Which are used in testing to assert on flow control stream state and
transitions.

Introduce another set of three tables, most of which are identical to the
exsting tables but populating the table data using rac2.

```
crdb_internal.kv_flow_controller_v2
crdb_internal.kv_flow_control_handles_v2
crdb_internal.kv_flow_token_deductions_v2
```

`crdb_internal.kv_flow_controller_v2` has two additional columns,
tracking the amount of available (regular|elastic) send tokens. The
schema is:

```
CREATE TABLE crdb_internal.kv_flow_controller_v2 (
  tenant_id                     INT NOT NULL,
  store_id                      INT NOT NULL,
  available_eval_regular_tokens INT NOT NULL,
  available_eval_elastic_tokens INT NOT NULL,
  available_send_regular_tokens INT NOT NULL,
  available_send_elastic_tokens INT NOT NULL
);
```

Note that unless rac2 is enabled, the tables are unlikely to show
anything interesting. Both tables (v1 and v2) are kept for
compatibility, with an intent to replace the v1 tables with the v2 ones
after v1 replication flow control is removed entirely from the code.

Resolves: cockroachdb#128091
Release note: None

Co-authored-by: Austen McClernon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-replication-admission-control-v2 Related to introduction of replication AC v2 C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-kv KV Team
Projects
No open projects
Status: Incoming
Development

Successfully merging a pull request may close this issue.

1 participant