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

Add VStreamerCount stat to vttablet #11978

Merged
merged 5 commits into from
Dec 20, 2022

Conversation

timvaillancourt
Copy link
Contributor

@timvaillancourt timvaillancourt commented Dec 15, 2022

Description

This PR adds the VStreamersActive VStreamerCount stats metric to vttablet to make the # of active streams more observable. There may be a way to infer this using rates from a combination of VStreamersCreated and other metrics but I was unable to do so myself (in Prometheus/Grafana) after many attempts so this feels like a rough edge

The length of the VStream engine streamers map is used as the number of active streams. This is done without a lock but I'm happy to add one

Related Issue(s)

Checklist

@vitess-bot
Copy link
Contributor

vitess-bot bot commented Dec 15, 2022

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • If this is a change that users need to know about, please apply the release notes (needs details) label so that merging is blocked unless the summary release notes document is included.

If a new flag is being introduced:

  • Is it really necessary to add this flag?
  • Flag names should be clear and intuitive (as far as possible)
  • Help text should be descriptive.
  • Flag names should use dashes (-) as word separators rather than underscores (_).

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow should be required, the maintainer team should be notified.

Bug fixes

  • There should be at least one unit or end-to-end test.
  • The Pull Request description should include a link to an issue that describes the bug.

Non-trivial changes

  • There should be some code comments as to why things are implemented the way they are.

New/Existing features

  • Should be documented, either by modifying the existing documentation or creating new documentation.
  • New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • vtctl command output order should be stable and awk-able.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from VTop, if used there.

@mattlord
Copy link
Contributor

Just a note that we'll need to document this new metric here on the vreplication metrics page: vitessio/website#1267

@timvaillancourt we should try and have you push directly to that PR. I can help get you setup with any access you need and walk you through it as needed.

@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Trivial Component: VReplication labels Dec 15, 2022
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Thank you! I also noticed this missing metric info today: https://vitess.slack.com/archives/C0PQY0PTK/p1671132033807179?thread_ts=1670952842.374699&cid=C0PQY0PTK

I had to look at the tablets' /debug/status endpoints to see where the vstreamer was running.

I would note that this is not only about vtgate<->vttablet vstreams but also vttablet<->vttablet vstreams such as are used for VReplication workflows after the copy phase. Just something to keep in mind as we think about this.

go/vt/vttablet/tabletserver/vstreamer/engine.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/vstreamer/engine.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/vstreamer/engine.go Outdated Show resolved Hide resolved
@timvaillancourt timvaillancourt changed the title Add VStreamersActive stat to vttablet Add VStreamerCount stat to vttablet Dec 15, 2022
@timvaillancourt
Copy link
Contributor Author

@mattlord thanks for the review! One question re: the mutex added and website PR on the way tomorrow 👍

@timvaillancourt
Copy link
Contributor Author

Hrm, re-requesting review from Matt dropped the other reviewers. My apologies 🤷

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

LGTM! ❤️

@timvaillancourt
Copy link
Contributor Author

timvaillancourt commented Dec 16, 2022

@timvaillancourt we should try and have you push directly to that PR. I can help get you setup with any access you need and walk you through it as needed.

@mattlord thanks! Website PR created here: vitessio/website#1291

Screenshot 2022-12-16 at 18 58 50

@@ -138,6 +138,7 @@ func NewEngine(env tabletenv.Env, ts srvtopo.Server, se *schema.Engine, lagThrot
errorCounts: env.Exporter().NewCountersWithSingleLabel("VStreamerErrors", "Tracks errors in vstreamer", "type", "Catchup", "Copy", "Send", "TablePlan"),
vstreamerFlushedBinlogs: env.Exporter().NewCounter("VStreamerFlushedBinlogs", "Number of times we've successfully executed a FLUSH BINARY LOGS statement when starting a vstream"),
}
env.Exporter().NewGaugeFunc("VStreamerCount", "Current number of vstreamers", vse.getVStreamerCount)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we instead use a stats.Gauge as a new field vstreamerCount in vstreamer.Engine? Then in vse.Stream(): vse.vstreamerCount.Add(1) while creating a stream and vse.vstreamerCount.Add(-1). stats.Gauge is an atomicInt64. We then avoid the mutex requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rohit-nayak-ps good idea, I'll make that change 👍

Copy link
Contributor Author

@timvaillancourt timvaillancourt Dec 19, 2022

Choose a reason for hiding this comment

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

@rohit-nayak-ps / @mattlord changes made in 5d889e0 and 2af4045

Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

LGTM (again)! 😄

Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

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

lgtm

Thanks! this is a useful new metric.

@rohit-nayak-ps rohit-nayak-ps merged commit 47a7cf8 into vitessio:main Dec 20, 2022
@timvaillancourt timvaillancourt deleted the stats-VStreamersActive branch December 20, 2022 18:55
DeathBorn pushed a commit to vinted/vitess that referenced this pull request Jan 25, 2023
* Add `VStreamersActive` stat to `vttablet`

Signed-off-by: Tim Vaillancourt <[email protected]>

* Improve desc

Signed-off-by: Tim Vaillancourt <[email protected]>

* Add PR suggestions

Signed-off-by: Tim Vaillancourt <[email protected]>

* Move to *stats.Gauge

Signed-off-by: Tim Vaillancourt <[email protected]>

* Single defer

Signed-off-by: Tim Vaillancourt <[email protected]>

Signed-off-by: Tim Vaillancourt <[email protected]>
timvaillancourt added a commit to slackhq/vitess that referenced this pull request Mar 30, 2023
* Add `VStreamersActive` stat to `vttablet`

Signed-off-by: Tim Vaillancourt <[email protected]>

* Improve desc

Signed-off-by: Tim Vaillancourt <[email protected]>

* Add PR suggestions

Signed-off-by: Tim Vaillancourt <[email protected]>

* Move to *stats.Gauge

Signed-off-by: Tim Vaillancourt <[email protected]>

* Single defer

Signed-off-by: Tim Vaillancourt <[email protected]>

Signed-off-by: Tim Vaillancourt <[email protected]>
timvaillancourt added a commit to slackhq/vitess that referenced this pull request Mar 30, 2023
* Add `VStreamersActive` stat to `vttablet`

Signed-off-by: Tim Vaillancourt <[email protected]>

* Improve desc

Signed-off-by: Tim Vaillancourt <[email protected]>

* Add PR suggestions

Signed-off-by: Tim Vaillancourt <[email protected]>

* Move to *stats.Gauge

Signed-off-by: Tim Vaillancourt <[email protected]>

* Single defer

Signed-off-by: Tim Vaillancourt <[email protected]>

Signed-off-by: Tim Vaillancourt <[email protected]>
timvaillancourt added a commit to slackhq/vitess that referenced this pull request May 21, 2024
* Add `VStreamersActive` stat to `vttablet`

Signed-off-by: Tim Vaillancourt <[email protected]>

* Improve desc

Signed-off-by: Tim Vaillancourt <[email protected]>

* Add PR suggestions

Signed-off-by: Tim Vaillancourt <[email protected]>

* Move to *stats.Gauge

Signed-off-by: Tim Vaillancourt <[email protected]>

* Single defer

Signed-off-by: Tim Vaillancourt <[email protected]>

Signed-off-by: Tim Vaillancourt <[email protected]>
timvaillancourt added a commit to slackhq/vitess that referenced this pull request May 22, 2024
* Add `VStreamerCount` stat to `vttablet` (vitessio#11978)

* Add `VStreamersActive` stat to `vttablet`

Signed-off-by: Tim Vaillancourt <[email protected]>

* Improve desc

Signed-off-by: Tim Vaillancourt <[email protected]>

* Add PR suggestions

Signed-off-by: Tim Vaillancourt <[email protected]>

* Move to *stats.Gauge

Signed-off-by: Tim Vaillancourt <[email protected]>

* Single defer

Signed-off-by: Tim Vaillancourt <[email protected]>

Signed-off-by: Tim Vaillancourt <[email protected]>

* Add `Uptime` metric (vitessio#12712)

* Add `Uptime` metric to `vtgate`+`vttablet`

Signed-off-by: Tim Vaillancourt <[email protected]>

* move to go/vt/servenv/status.go

Signed-off-by: Tim Vaillancourt <[email protected]>

* Use nanoseconds for uptime

Signed-off-by: Tim Vaillancourt <[email protected]>

* Move Uptime metrics to servenv.go, remove dupe start time.Time

Signed-off-by: Tim Vaillancourt <[email protected]>

* Use serverStart time.Time

Signed-off-by: Tim Vaillancourt <[email protected]>

---------

Signed-off-by: Tim Vaillancourt <[email protected]>

* Implement the RowsColumnTypeScanType interface in the go sql driver for Vitess in order to get the column types (vitessio#12007)

Signed-off-by: Johan Oskarsson <[email protected]>

Signed-off-by: Johan Oskarsson <[email protected]>
Co-authored-by: Johan Oskarsson <[email protected]>

* Add vstream metrics to vtgate (vitessio#13098)

* Add vstream metrics to vtgate

Signed-off-by: twthorn <[email protected]>

* Update unit test name and use cell variable

Signed-off-by: twthorn <[email protected]>

* Reset metrics for TestVStreamsCreatedAndLagMetrics, fix data race issue

Signed-off-by: twthorn <[email protected]>

---------

Signed-off-by: twthorn <[email protected]>

* add lock to flaky TestValidateVersionShard test

Signed-off-by: Tim Vaillancourt <[email protected]>

* typo

Signed-off-by: Tim Vaillancourt <[email protected]>

---------

Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Johan Oskarsson <[email protected]>
Signed-off-by: twthorn <[email protected]>
Co-authored-by: Johan Oskarsson <[email protected]>
Co-authored-by: Johan Oskarsson <[email protected]>
Co-authored-by: Thomas Thornton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VReplication Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants