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

tree: move telemetry references to sql package #80771

Merged
merged 9 commits into from
May 17, 2022

Conversation

otan
Copy link
Contributor

@otan otan commented Apr 29, 2022

Individual commits should be fairly easy to review by themselves!

There are still indirect references as of writing, but this removes the direct ones!

@otan otan requested review from ajwerner and a team April 29, 2022 05:48
@otan otan requested a review from a team as a code owner April 29, 2022 05:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan force-pushed the more_remove_telem branch 4 times, most recently from 383e6d8 to 4526c12 Compare April 29, 2022 07:12
@otan
Copy link
Contributor Author

otan commented Apr 29, 2022

hmm, the last commit causes


fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0x70eaa78 pc=0x102dab7f8]

goroutine 2895 [running]:
runtime.throw({0x105fb7b77, 0x2a})
	/opt/homebrew/opt/[email protected]/libexec/src/runtime/panic.go:1198 +0x54 fp=0x14004da7150 sp=0x14004da7120 pc=0x102dcf964
runtime.sigpanic()
	/opt/homebrew/opt/[email protected]/libexec/src/runtime/signal_unix.go:719 +0x230 fp=0x14004da7190 sp=0x14004da7150 pc=0x102de84c0
runtime.heapBitsSetType(0x14004f6a8f0, 0xd0, 0xc8, 0x107aee6c0)
	/opt/homebrew/opt/[email protected]/libexec/src/runtime/mbitmap.go:1119 +0x608 fp=0x14004da7260 sp=0x14004da71a0 pc=0x102dab7f8
runtime.mallocgc(0xc8, 0x107aee6c0, 0x1)
	/opt/homebrew/opt/[email protected]/libexec/src/runtime/malloc.go:1106 +0x654 fp=0x14004da72f0 sp=0x14004da7260 pc=0x102da3074
runtime.newobject(0x107aee6c0)
	/opt/homebrew/opt/[email protected]/libexec/src/runtime/malloc.go:1234 +0x38 fp=0x14004da7320 sp=0x14004da72f0 pc=0x102da3488
github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scdeps.NewJobRunDependencies(...)
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scdeps/run_deps.go:49
github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scjob.(*newSchemaChangeResumer).run(0x14004e4b310, {0x107c72858, 0x140053dbe90}, {0x1079c4660, 0x1400078a148})
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scjob/job.go:66 +0x2a4 fp=0x14004da7620 sp=0x14004da7320 pc=0x105c63c84
github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scjob.(*newSchemaChangeResumer).Resume(0x14004e4b310, {0x107c72858, 0x140053dbe90}, {0x1079c4660, 0x1400078a148})
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scjob/job.go:42 +0x48 fp=0x14004da7670 sp=0x14004da7620 pc=0x105c63938
github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine.func2(0x140013be580, 0x14001990500, {0x107c02688, 0x14004e4b310}, {0x107c72858, 0x140053dbe90}, {0x1079c4660, 0x1400078a148}, 0x14004da78c0)
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1168 +0xec fp=0x14004da76e0 sp=0x14004da7670 pc=0x1045b182c
github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine(0x14001990500, {0x107c72858, 0x14003950780}, {0x1079c4660, 0x1400078a148}, {0x107c02688, 0x14004e4b310}, 0x140014ac680, {0x14004e4f130, 0x7}, ...)
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1169 +0x670 fp=0x14004da7cb0 sp=0x14004da76e0 pc=0x1045b00d0
github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).runJob(0x14001990500, {0x107c727b0, 0x14000f7fd80}, {0x107c02688, 0x14004e4b310}, 0x140014ac680, {0x14004e4f130, 0x7}, {0x14002c5a330, 0x16})
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:408 +0x554 fp=0x14004da7e60 sp=0x14004da7cb0 pc=0x10459b914
github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob.func1({0x107c72858, 0x140039504b0})
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:329 +0x100 fp=0x14004da7f20 sp=0x14004da7e60 pc=0x10459b1a0
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2(0x140013b3290, {0x107c72858, 0x140039504b0}, 0x14001262900, 0x0, 0x14004e6b720)
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:494 +0xf8 fp=0x14004da7fa0 sp=0x14004da7f20 pc=0x1039d5278
runtime.goexit()
	/opt/homebrew/opt/[email protected]/libexec/src/runtime/asm_arm64.s:1133 +0x4 fp=0x14004da7fa0 sp=0x14004da7fa0 pc=0x102e06a74
created by github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx
	/Users/otan/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:483 +0x384

when i run logic tests locally (make testbaselogic FILES='geospatial'), which is confusing...

locally but not on CI though o_o"

@otan otan force-pushed the more_remove_telem branch 2 times, most recently from 4892c69 to 1a42f0d Compare April 29, 2022 08:31
otan added 9 commits May 3, 2022 08:18
Woops - wrong name used! Intending to backport this to v22.1.

Release note: None
Make the map of counters public and only referencing a function, and
move initialization to the sql package.

Release note: None
@otan otan force-pushed the more_remove_telem branch from 1a42f0d to c2138b7 Compare May 2, 2022 22:19
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.

Can I be annoying? How would you feel about factoring this out even more so that each of these call sites can just pass in the tree node? We're going to want to record the same telemetry in the declarative schema changer. It'll be easier to factor that out if there's a centralized entry point. I think it'll also make adding future telemetry easier.

Reviewed 2 of 2 files at r1, 4 of 4 files at r2, 2 of 2 files at r3, 2 of 4 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner)

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.

Of all the PRs, this one makes me feel the most gross.

Reviewed 2 of 4 files at r4, 4 of 4 files at r5, 4 of 4 files at r6, 1 of 5 files at r7.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @otan)


pkg/sql/sem/tree/alter_table.go line 146 at r5 (raw file):

//
//     ALTER TABLE t ADD COLUMN a INT CHECK (a < b)
func (node *AlterTable) HoistAddColumnConstraints(onHoistedFKConstraint func()) {

:/ this definitely does not feel good

@otan
Copy link
Contributor Author

otan commented May 3, 2022

Can you give an example of usage of what you mean by what you just said?

@ajwerner
Copy link
Contributor

ajwerner commented May 3, 2022

Instaed of each of these:

telemetry.Inc(sqltelemetry.SchemaChangeAlterCounterWithExtra(
		tree.GetTableType(n.n.IsSequence, n.n.IsView, n.n.IsMaterialized),
		n.n.TelemetryName(),
	))
	telemetry.Inc(sqltelemetry.SchemaChangeAlterCounterWithExtra("type", n.n.Cmd.TelemetryName()))
	telemetry.Inc(sqltelemetry.SchemaChangeDropCounter(
		tree.GetTableType(false /* isSequence */, true /* isView */, n.n.IsMaterialized),
	))

Have:

func incrementTelemetryCounter(n tree.Statement) {
   switch n := n.(type) {
   case *tree.DropView:
     	telemetry.Inc(sqltelemetry.SchemaChangeDropCounter(
		tree.GetTableType(false /* isSequence */, true /* isView */, n.n.IsMaterialized),
	))
    case *tree.AlterType:
	telemetry.Inc(sqltelemetry.SchemaChangeAlterCounterWithExtra("type", n.n.Cmd.TelemetryName()))
    case *tree.AlterTableSetSchema:
	telemetry.Inc(sqltelemetry.SchemaChangeAlterCounterWithExtra(
		tree.GetTableType(n.n.IsSequence, n.n.IsView, n.n.IsMaterialized),
		n.n.TelemetryName(),
	))
   }
}

@ajwerner
Copy link
Contributor

ajwerner commented May 3, 2022

Maybe you should just wave me off

@otan
Copy link
Contributor Author

otan commented May 3, 2022

func incrementTelemetryCounter(n tree.Statement)

D: i'm a bigger fan of this way as its statically coded that the TelemetryName exists. but if you feel super strong about it, i guess i can do that.

(edit: currently i have decided not to)

@otan otan requested a review from rafiss May 12, 2022 23:26
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.

Works for me.

@otan
Copy link
Contributor Author

otan commented May 17, 2022

bors r=ajwerner

thanks!

@craig
Copy link
Contributor

craig bot commented May 17, 2022

Build succeeded:

@craig craig bot merged commit dc79c28 into cockroachdb:master May 17, 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