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

sql: proper version gate sql stats #69592

Merged
merged 1 commit into from
Aug 30, 2021

Conversation

Azhng
Copy link
Contributor

@Azhng Azhng commented Aug 30, 2021

Previously, SQL Stats's implementation for version gating is faulty.
This means that SQL Stats's job monitor would attempt to start sql
stats compaction job in an incompatible cluster.
This commit fixed the faulty implementation.

Resolves #69459
Resolves #69544
Resolves #69565

Release justification: Category 2: Bug fixes and low-risk updates to
new functionality

Release note: None

@Azhng Azhng requested review from ajwerner and a team August 30, 2021 16:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@ajwerner ajwerner 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 @Azhng)


pkg/sql/sqlstats/persistedsqlstats/scheduled_job_monitor.go, line 145 at r1 (raw file):

func (j *jobMonitor) ensureSchedule(ctx context.Context) {
	if !j.isVersionCompatible(ctx) {
		log.Error(ctx, "cannot create sql stats scheduled compaction job because current cluster version is too low")

This isn't an error, right? I think this is a normal situation in the mixed version state. Maybe log.Infof at worst. Also, use Infof even with no parameters. Otherwise we'll redact it.

Copy link
Contributor Author

@Azhng Azhng 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 @ajwerner)


pkg/sql/sqlstats/persistedsqlstats/scheduled_job_monitor.go, line 145 at r1 (raw file):

Previously, ajwerner wrote…

This isn't an error, right? I think this is a normal situation in the mixed version state. Maybe log.Infof at worst. Also, use Infof even with no parameters. Otherwise we'll redact it.

Ah I misunderstood the earlier comment on the issue. Switched to log.Infof

Copy link
Contributor

@ajwerner ajwerner 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 @Azhng)


pkg/sql/sqlstats/persistedsqlstats/scheduled_job_monitor.go, line 176 at r2 (raw file):

Quoted 5 lines of code…
	clusterVersion := j.st.Version.ActiveVersionOrEmpty(ctx)
	if !clusterVersion.IsActive(clusterversion.SQLStatsCompactionScheduledJob) {
		return false
	}
	return true

Why not just st.Version.IsActive(ctx, clusterversion.SQLStatsCompactionScheduledJob)?

Copy link
Contributor Author

@Azhng Azhng 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 @Azhng)


pkg/sql/sqlstats/persistedsqlstats/scheduled_job_monitor.go, line 176 at r2 (raw file):

Previously, ajwerner wrote…
	clusterVersion := j.st.Version.ActiveVersionOrEmpty(ctx)
	if !clusterVersion.IsActive(clusterversion.SQLStatsCompactionScheduledJob) {
		return false
	}
	return true

Why not just st.Version.IsActive(ctx, clusterversion.SQLStatsCompactionScheduledJob)?

Done.

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

:lgtm:

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


pkg/sql/sqlstats/persistedsqlstats/scheduled_job_monitor.go, line 93 at r3 (raw file):

		}
		if err := j.db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error {
			j.ensureSchedule(ctx)

It feels bizarre to me to do this inside of the transaction. How about doing this two lines up?

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r1, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng)


pkg/sql/sqlstats/persistedsqlstats/job_monitor_test.go, line 55 at r4 (raw file):

	sqlDB.Exec(t, "SET CLUSTER SETTING sql.stats.cleanup.recurrence = '@daily'")

	// Wait for the change is picked up by the job monitor.

nit: change to be picked

Previously, SQL Stats's implementation for version gating is faulty.
This means that SQL Stats's job monitor would attempt to start sql
stats compaction job in an incompatible cluster.
This commit fixed the faulty implementation.

Resolves cockroachdb#69459
Resolves cockroachdb#69541
Resolves cockroachdb#69544
Resolves cockroachdb#69565

Release justification: Category 2: Bug fixes and low-risk updates to
new functionality

Release note: None
Copy link
Contributor Author

@Azhng Azhng 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 (and 1 stale) (waiting on @Azhng)


pkg/sql/sqlstats/persistedsqlstats/job_monitor_test.go, line 55 at r4 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: change to be picked

Done.

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng)

@Azhng
Copy link
Contributor Author

Azhng commented Aug 30, 2021

TFTR!

bors r=maryliag,ajwerner

@craig
Copy link
Contributor

craig bot commented Aug 30, 2021

Build succeeded:

@craig craig bot merged commit e76382b into cockroachdb:master Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants