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

feat(stmt): support config maximum number of stmt kept in memory #914

Merged
merged 5 commits into from
May 11, 2021

Conversation

shhdgit
Copy link
Member

@shhdgit shhdgit commented May 10, 2021

Related: #910

image

name="max_size"
label={t('statement.settings.max_size')}
>
<InputNumber min={1} />
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need a limit on the maximum value?

@shhdgit
Copy link
Member Author

shhdgit commented May 10, 2021

/cc @breeswish @baurine
PTAL.

@ti-chi-bot ti-chi-bot requested review from baurine and breezewish May 10, 2021 05:02
Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

Nice refinement!

err := updateStmtConfig(db, &req)

if !config.Enable {
err = db.Exec(buildConfigUpdateSQL(&config, "Enable")).Error
Copy link
Member

Choose a reason for hiding this comment

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

What does this Enable do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Extract fields from struct, only the extract fields will be left in SQL.

Like this:

func (t *testConfigSuite) Test_buildConfigUpdateSQL_extract_fields(c *C) {
	testConfigStmt := "SET @@GLOBAL.tidb_enable_stmt_summary = true"
	c.Assert(buildConfigUpdateSQL(&testConfig{Enable: true, RefreshInterval: 1800}, "Enable"), Equals, testConfigStmt)
}

pkg/apiserver/statement/config.go Outdated Show resolved Hide resolved

val := configValue.Field(i)
column := utils.GetGormColumnName(gormTag)
stmts = append(stmts, fmt.Sprintf("@@GLOBAL.%s = %v", column, val))
Copy link
Member

Choose a reason for hiding this comment

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

Seems that val may lead to security risks as it can be anything!

Copy link
Member Author

Choose a reason for hiding this comment

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

Right...Let me think about it.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can use parameterized queries. It will be very safe.

Copy link
Member Author

@shhdgit shhdgit May 11, 2021

Choose a reason for hiding this comment

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

For now, buildConfigQuerySQL is only used by configHandler service. And reflect.Value's type is determined. Maybe we can do this refinement after #916 ?

Copy link
Member

Choose a reason for hiding this comment

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

Looks good!

pkg/apiserver/statement/config.go Outdated Show resolved Hide resolved
pkg/apiserver/statement/config.go Outdated Show resolved Hide resolved
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • breeswish

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@breezewish
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 3b3a849

@CLAassistant
Copy link

CLAassistant commented May 11, 2021

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot merged commit 7f9085e into pingcap:master May 11, 2021
shhdgit added a commit to shhdgit/tidb-dashboard that referenced this pull request May 12, 2021
breezewish pushed a commit that referenced this pull request May 12, 2021
* fix(ttlcache): goroutine leak (#892)
* tidb: forwarder only uses tidb whose status is Up (#893)
* keyviz: Add tips for enabled config (#901)
* ui: rocksdb fields (#896)
* monitoring: setup sentry (#895)
* tidb_client: improve behavior when no alive tidb instance (#900)
* feat(stmt): support config maximum number of stmt kept in memory (#914)
* feat: debug api (#898)
* ui: Improve settings description for Statement (#920)
* feat(ui): add tiflash profiling option (#859)
* ui: Add a warning for the debug API (#922)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants