Skip to content

Comments

ttljob: add row statistics#76837

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
otan-cockroach:auto_status
Mar 2, 2022
Merged

ttljob: add row statistics#76837
craig[bot] merged 1 commit intocockroachdb:masterfrom
otan-cockroach:auto_status

Conversation

@otan
Copy link
Contributor

@otan otan commented Feb 21, 2022

This commit adds the ability for the TTL job to generate statistics on
number of rows and number of expired rows on the table. This is off by
default, controllable by the ttl_automatic_stats_poll_interval storage
parameter syntax.

Release justification: low risk high benefit changes to new
functionality

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan mentioned this pull request Feb 21, 2022
30 tasks
@otan otan requested a review from rafiss February 22, 2022 11:09
@otan otan force-pushed the auto_status branch 2 times, most recently from f713341 to cc0f20f Compare February 22, 2022 20:54
@otan otan marked this pull request as ready for review February 23, 2022 09:02
@otan otan requested a review from a team February 23, 2022 09:02
@otan otan force-pushed the auto_status branch 2 times, most recently from 3173a3c to 714e75f Compare February 23, 2022 09:45
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

small suggestions

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @rafiss)


pkg/sql/paramparse/paramparse.go, line 60 at r1 (raw file):

}

// DatumAsDuration transforms a tree.TypedExpr containing a Datum into a float.

nit: into a Duration


pkg/sql/paramparse/paramparse.go, line 79 at r1 (raw file):

		d = v.Duration
	default:
		err = pgerror.Newf(pgcode.InvalidParameterValue,

should we allow DInts here? doesn't seem that important, just curious


pkg/sql/ttl/ttljob/ttljob.go, line 373 at r1 (raw file):

	)

	statsCloseCh := make(chan struct{})

nit: should the channel have a size of 1?


pkg/sql/ttl/ttljob/ttljob.go, line 408 at r1 (raw file):

	if ttlSettings.RowStatsPollInterval != 0 {
		g.GoCtx(func(ctx context.Context) error {

random thought: i'm not familiar with this part of the code, but should this use RunAsyncTask?


pkg/sql/ttl/ttljob/ttljob.go, line 566 at r1 (raw file):

					ctx,
					c.opName,
					txn,

nit: seems like it could be simpler to pass in a nil txn. then you can get rid of the DB.Txn and SET TRANSACTION parts, just need to keep:

				datums, err := execCfg.InternalExecutor.QueryRow(
					ctx,
					c.opName,
					nil,
					fmt.Sprintf(c.query, details.TableID),
					c.args...,
				)
				if err != nil {
					return err
				}
				c.gauge.Update(int64(*datums[0].(*tree.DInt)))
				return nil

and modify c.query so it has an AOST clause


pkg/sql/ttl/ttljob/ttljob.go, line 573 at r1 (raw file):

					return err
				}
				c.gauge.Update(int64(*datums[0].(*tree.DInt)))

nit: use tree.MustBeDInt

Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/paramparse/paramparse.go, line 79 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

should we allow DInts here? doesn't seem that important, just curious

not imo, would that be s or ms or ns ...


pkg/sql/ttl/ttljob/ttljob.go, line 373 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

nit: should the channel have a size of 1?

no, it's just closed and not used in any way.


pkg/sql/ttl/ttljob/ttljob.go, line 408 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

random thought: i'm not familiar with this part of the code, but should this use RunAsyncTask?

runasynctask doesn't have a way to wait(). i'd rather goroutines be accounted for (for now) and block wait at the end

@otan otan force-pushed the auto_status branch 3 times, most recently from 4c9cc3d to 57ba903 Compare February 28, 2022 11:05
@otan otan requested a review from a team February 28, 2022 11:05
@otan otan requested a review from rafiss February 28, 2022 20:32
Release note (sql change): This commit adds the ability for the TTL job
to generate statistics on number of rows and number of expired rows on
the table. This is off by default, controllable by the
`ttl_row_stats_poll_interval` storage parameter syntax.

Release justification: high benefit changes to new functionality
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @rafiss)


pkg/sql/ttl/ttljob/ttljob.go, line 420 at r2 (raw file):

					return nil
				case <-time.After(ttlSettings.RowStatsPollInterval):
					fetchStatistics(ctx, p.ExecCfg(), details, metrics, aostDuration)

hm, obviously this compiled, but a bit confused how since nothing gets returned in this branch.

Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

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

bors r=rafiss

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/ttl/ttljob/ttljob.go, line 420 at r2 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

hm, obviously this compiled, but a bit confused how since nothing gets returned in this branch.

it's in a for loop so continuously executes until stats is closed

@craig
Copy link
Contributor

craig bot commented Mar 2, 2022

Build succeeded:

@craig craig bot merged commit bb54797 into cockroachdb:master Mar 2, 2022
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.

3 participants