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

metrics(ticdc): add some log and metrics to owner and processorManage… #4402

Merged

Conversation

CharlesCheung96
Copy link
Contributor

@CharlesCheung96 CharlesCheung96 commented Jan 19, 2022

What problem does this PR solve?

Issue Number: close #3884

What is changed and how it works?

add some log and metrics to owner and processorManager to detect stuck scenario

Check List

Code changes

  • None

Side effects

  • Increased code complexity

Related changes

  • None

Release note

Add some log and metrics to owner and processorManager to detect stuck scenario

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • amyangfei
  • asddongmen

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 19, 2022
@3AceShowHand 3AceShowHand self-requested a review January 19, 2022 10:01
@3AceShowHand
Copy link
Contributor

/run-all-tests

@CharlesCheung96 CharlesCheung96 force-pushed the fix_3884_add_log_to_detect_stuck branch from 10e35c4 to ced7a7d Compare January 20, 2022 02:12
@CharlesCheung96
Copy link
Contributor Author

/run-all-tests

if costTime > changefeedLogsWarnDuration {
log.Warn("changefeed tick took too long", zap.String("changefeed", changefeedID), zap.Duration("duration", costTime))
}
changefeedReactorTickDuration.WithLabelValues(changefeedID).Observe(costTime.Seconds())
Copy link
Contributor

@amyangfei amyangfei Jan 21, 2022

Choose a reason for hiding this comment

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

We should avoid using WithLabelValues to create metric observer in hot path, which will cost too much CPU.
A better solution is to pre allocate prometheus labels and reuse the observer, such as what we use in processor

metricResolvedTsGauge: resolvedTsGauge.WithLabelValues(changefeedID, advertiseAddr),
metricResolvedTsLagGauge: resolvedTsLagGauge.WithLabelValues(changefeedID, advertiseAddr),
metricMinResolvedTableIDGuage: resolvedTsMinTableIDGauge.WithLabelValues(changefeedID, advertiseAddr),
metricCheckpointTsGauge: checkpointTsGauge.WithLabelValues(changefeedID, advertiseAddr),
metricCheckpointTsLagGauge: checkpointTsLagGauge.WithLabelValues(changefeedID, advertiseAddr),
metricMinCheckpointTableIDGuage: checkpointTsMinTableIDGauge.WithLabelValues(changefeedID, advertiseAddr),
metricSyncTableNumGauge: syncTableNumGauge.WithLabelValues(changefeedID, advertiseAddr),
metricProcessorErrorCounter: processorErrorCounter.WithLabelValues(changefeedID, advertiseAddr),
metricSchemaStorageGcTsGauge: processorSchemaStorageGcTsGauge.WithLabelValues(changefeedID, advertiseAddr),

@CharlesCheung96 CharlesCheung96 force-pushed the fix_3884_add_log_to_detect_stuck branch from ced7a7d to ad7df9d Compare January 21, 2022 09:14
@CharlesCheung96 CharlesCheung96 added the area/ticdc Issues or PRs related to TiCDC. label Jan 21, 2022
@CharlesCheung96 CharlesCheung96 force-pushed the fix_3884_add_log_to_detect_stuck branch from d279324 to c55d844 Compare January 21, 2022 13:56
@CharlesCheung96
Copy link
Contributor Author

/run-all-tests

@CharlesCheung96
Copy link
Contributor Author

/run-kafka-integration-tests
/run-integration-tests

@@ -128,6 +132,17 @@ func (c *changefeed) Tick(ctx cdcContext.Context, state *orchestrator.Changefeed
Message: err.Error(),
})
c.releaseResources(ctx)
} else {
// c.initialize(ctx)
costTime := time.Since(startTime)
Copy link
Contributor

Choose a reason for hiding this comment

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

May be it is better to rewrite the whole if block as:

err := c.tick()
costTime = time.Since(startTime)
// warn log here
if err != nil {
    ...
}
... 

Copy link
Contributor

@ben1009 ben1009 left a comment

Choose a reason for hiding this comment

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


[2022-01-25T02:45:17.902Z] === Failed

[2022-01-25T02:45:17.902Z] === FAIL: pkg/etcd TestGetOwnerRevision (11.99s)

[2022-01-25T02:45:17.902Z]     etcd_test.go:418: 

[2022-01-25T02:45:17.902Z]         	Error Trace:	etcd_test.go:418

[2022-01-25T02:45:17.902Z]         	            				asm_amd64.s:1371

[2022-01-25T02:45:17.902Z]         	Error:      	"etcdserver: request timed out" does not contain "context canceled"

[2022-01-25T02:45:17.902Z]         	Test:       	TestGetOwnerRevision

[2022-01-25T02:45:17.902Z]     etcd_test.go:418: 

[2022-01-25T02:45:17.902Z]         	Error Trace:	etcd_test.go:418

[2022-01-25T02:45:17.902Z]         	            				asm_amd64.s:1371

[2022-01-25T02:45:17.902Z]         	Error:      	"rpc error: code = Unknown desc = context deadline exceeded" does not contain "context canceled"

[2022-01-25T02:45:17.902Z]         	Test:       	TestGetOwnerRevision

[2022-01-25T02:45:17.902Z] ==================

[2022-01-25T02:45:17.902Z] WARNING: DATA RACE

[2022-01-25T02:45:17.902Z] Write at 0x00c000f03ea1 by goroutine 163:

[2022-01-25T02:45:17.902Z]   testing.(*common).FailNow()

[2022-01-25T02:45:17.902Z]       /usr/local/go/src/testing/testing.go:740 +0x4f

[2022-01-25T02:45:17.902Z]   testing.(*T).FailNow()

[2022-01-25T02:45:17.902Z]       <autogenerated>:1 +0x44

[2022-01-25T02:45:17.902Z]   github.com/stretchr/testify/require.Contains()

[2022-01-25T02:45:17.902Z]       /go/pkg/mod/github.com/stretchr/testify@v1.7.0/require/require.go:50 +0x124

[2022-01-25T02:45:17.902Z]   github.com/pingcap/tiflow/pkg/etcd.TestGetOwnerRevision.func1()

@@ -65,13 +69,34 @@ var (
Name: "status",
Help: "The status of changefeeds",
}, []string{"changefeed"})
changefeedTickDuration = prometheus.NewHistogramVec(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a screenshot after the metric applied make things more clear, the dashboard template will be added later ?

@CharlesCheung96 CharlesCheung96 force-pushed the fix_3884_add_log_to_detect_stuck branch from 34108fc to 8975c79 Compare January 26, 2022 03:59
@CharlesCheung96
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 26, 2022
@amyangfei amyangfei added the component/metrics-logging Metrics and logging component. label Jan 26, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 7, 2022
@CharlesCheung96
Copy link
Contributor Author

/run-all-tests

@codecov-commenter
Copy link

codecov-commenter commented Feb 8, 2022

Codecov Report

Merging #4402 (8ef0148) into master (9607554) will decrease coverage by 0.2072%.
The diff coverage is 55.2425%.

Flag Coverage Δ
cdc 60.1109% <67.1532%> (+0.1886%) ⬆️
dm 51.5270% <51.9920%> (-0.5019%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             master      #4402        +/-   ##
================================================
- Coverage   55.6402%   55.4329%   -0.2073%     
================================================
  Files           494        498         +4     
  Lines         61283      61826       +543     
================================================
+ Hits          34098      34272       +174     
- Misses        23750      24109       +359     
- Partials       3435       3445        +10     

@amyangfei
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 8ef0148

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 8, 2022
@ti-chi-bot
Copy link
Member

@CharlesCheung96: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@CharlesCheung96
Copy link
Contributor Author

/run-kafka-integration-tests

@ti-chi-bot ti-chi-bot merged commit c4f8055 into pingcap:master Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ticdc Issues or PRs related to TiCDC. component/metrics-logging Metrics and logging component. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more log for IO wait in owner to detect stuck
7 participants