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

server: create api to trigger table metadata update job #130721

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

kyle-a-wong
Copy link
Contributor

@kyle-a-wong kyle-a-wong commented Sep 13, 2024

adds a new API v2 endpoint,
POST /api/v2/table_metadata/updatejob.

server: create api to trigger table metadata update job

adds a new API v2 endpoint,
POST /api/v2/table_metadata/updatejob.

This new API will trigger the table metadata update job
to run and refresh the system.table_metadata table.

This will only trigger the job if it isn't already
running. If the ?onlyIfStale query param is
provided, the job won't be triggered unless deemed
stale, determined by the following setting:
obs.tablemetadata.data_valid_duration

note that onlyIfStale with any value other then
false will be treated as true.

Resolves: #128897
Epic: CRDB-37558
Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@kyle-a-wong kyle-a-wong force-pushed the trigger_update_job_api branch 3 times, most recently from 013a51c to 20e46e0 Compare September 16, 2024 14:53
@kyle-a-wong kyle-a-wong marked this pull request as ready for review September 16, 2024 14:56
@kyle-a-wong kyle-a-wong requested review from a team as code owners September 16, 2024 14:56
@kyle-a-wong kyle-a-wong requested review from xinhaoz, dhartunian and angles-n-daemons and removed request for a team September 16, 2024 14:56
pkg/server/api_v2_databases_metadata.go Outdated Show resolved Hide resolved
pkg/server/api_v2_databases_metadata_test.go Outdated Show resolved Hide resolved
@kyle-a-wong kyle-a-wong force-pushed the trigger_update_job_api branch 9 times, most recently from c6dc399 to afcf872 Compare September 20, 2024 18:29
@kyle-a-wong kyle-a-wong requested a review from a team as a code owner September 20, 2024 18:29
@kyle-a-wong kyle-a-wong removed the request for review from a team September 20, 2024 18:29
@kyle-a-wong kyle-a-wong force-pushed the trigger_update_job_api branch 3 times, most recently from c49c4d9 to 3479f41 Compare September 20, 2024 20:54
Copy link
Member

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

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

Nice! Excited to connect this to the new pages. Mostly testing comments - feel free to merge after addressing them.

pkg/server/api_v2_databases_metadata_test.go Show resolved Hide resolved
pkg/server/api_v2_databases_metadata_test.go Outdated Show resolved Hide resolved
pkg/server/api_v2_databases_metadata_test.go Show resolved Hide resolved
@@ -4211,7 +4211,7 @@ func (s *statusServer) localUpdateTableMetadataCache() (
select {
case s.updateTableMetadataJobSignal <- struct{}{}:
default:
return nil, status.Errorf(codes.Unavailable, "update table metadata cache job is not ready to start execution")
return nil, status.Errorf(codes.Aborted, "update table metadata cache job is not ready to start execution")
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, why the switch to aborted here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that typically, the unavailable status should be used for when the service is temporarily unavailable, where as the aborted status should be used when an operation is aborted. To me this case falls under an latter.

adds a new API v2 endpoint,
`POST /api/v2/table_metadata/updatejob`.

This new API will trigger the table metadata update job
to run and refresh the system.table_metadata table.

This will only trigger the job if it isn't already
running. If the `?onlyIfStale` query param is
provided, the job won't be triggered unless deemed
stale, determined by the following setting:
 `obs.tablemetadata.data_valid_duration`

note that `onlyIfStale` with any value other then
`false` will be treated as true.

Resolves: cockroachdb#128897
Epic: CRDB-37558
Release note: None
@kyle-a-wong
Copy link
Contributor Author

tftr

bors r+

@craig craig bot merged commit f1955eb into cockroachdb:master Sep 23, 2024
23 checks passed
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.

Create new HTTP API to triggering the table metadata update job
3 participants