cockroachdb / cockroachdb/cockroach

jobs: use methods instead of closures for queries

Open
#146,801 2 comments 0 reactions 0 assignees View on GitHub
A-disaster-recovery A-jobs C-enhancement T-disaster-recovery
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

When looking at a goroutine dump of the job system it looks like:

```
github.com/cockroachdb/cockroach/pkg/sql.(*ieResultChannel).firstResult(0xc091000280, {0x8669be0, 0xc02082c180})
pkg/sql/internal_result_channel.go:118 +0xfc
github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).execInternal(_, {_, _}, {_, _}, _, _, _, {{{0x6d8df68, 0x4}}, ...}, ...)
pkg/sql/internal.go:1374 +0xf70
github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).execIEStmt(0xc085a6dd60, {0x8669ba8, _}, {_, _}, _, {{{0x6d8df68, 0x4}}, {0x0, 0x0}, ...}, ...)
pkg/sql/internal.go:861 +0x1c5
github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).ExecEx(...)
pkg/sql/internal.go:816
github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).Start.func2.1({0x8669ba8, 0xc085a19450}, {0x86edb68, 0xc085a6dd60})
```

This is a side effect of how the job system is implemented. It has a bunch of periodic queries that are injected as closures. It this was an interface with methods it would be much easier to determine that this query is the dead session cleanup query (vs the adopt query or the cancellation query).

Jira issue: CRDB-50716

Epic CRDB-50858

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.