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

session: add no register API for using TiDB as a library #17513

Merged
merged 20 commits into from
Jul 14, 2020

Conversation

YuJuncen
Copy link
Contributor

@YuJuncen YuJuncen commented May 29, 2020

What problem does this PR solve?

Issue Number: close br#299

Problem Summary:

BR uses TiDB as a library, but currently when we call session.GetDomain, domap.Get will automatically register itself to PD. Then a strange TiDB will present at dashboard.

see more at br#299.

What is changed and how it works?

What's Changed:

I added a config option no-register to TiDB.

Then, when this is enabled, topologySyncer won't be started, hence this TiDB won't register itself to dashboard.

How it Works:

We add a if-guard to where initializing topologySyncer at infoSyncer.Init and Session.Init.

Check List

Tests

  • Manual test (add detailed scripts or steps below)
    • I replace this version of TiDB to BR, and set no-register = true, then BR won't register it self as a TiDB anymore.

More things

Maybe we have more things to do, for now please add WIP tag for this:

  • Add test cases. (IMO, this is too hard to be tested automatically.)
  • Don't make NoRegistered TiDB become DDL owner. (We can set run-DDL = false)

Release note

  • No release note

@CLAassistant
Copy link

CLAassistant commented May 29, 2020

CLA assistant check
All committers have signed the CLA.

@sre-bot
Copy link
Contributor

sre-bot commented May 29, 2020

@codecov
Copy link

codecov bot commented May 29, 2020

Codecov Report

Merging #17513 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #17513   +/-   ##
===========================================
  Coverage   79.3272%   79.3272%           
===========================================
  Files           541        541           
  Lines        145636     145636           
===========================================
  Hits         115529     115529           
  Misses        20812      20812           
  Partials       9295       9295           

@YuJuncen
Copy link
Contributor Author

YuJuncen commented May 29, 2020

@breeswish PTAL, or... Please add some labels...

@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label May 29, 2020
@bb7133
Copy link
Member

bb7133 commented Jun 1, 2020

When BR is integrated into TiDB, we don't need this PR, right? I think the integration is very close.

domain/domain.go Outdated
@@ -655,6 +655,14 @@ func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duratio

// Init initializes a domain.
func (do *Domain) Init(ddlLease time.Duration, sysFactory func(*Domain) (pools.Resource, error)) error {
if err := do.InitWithNoRegister(ddlLease, sysFactory); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This also disables the DDL syncer, will it cause problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems InfoSyncer won't do things about DDL... Is there something I ignored...?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how BR uses the DDL structure. If BR uses InitWithNoRegister to new a DDL, then the DDL also will campaign DDL owner, but it will make load schema slower then Init with InfoSyncer. Is it OK?

session/tidb.go Outdated Show resolved Hide resolved
@@ -149,6 +149,9 @@ func (is *InfoSyncer) init(ctx context.Context) error {
if err != nil {
return err
}
if config.GetGlobalConfig().NoRegister {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'd better to use config.GetGlobalConfig().NoRegister as a argument to GlobalInfoSyncerInit. It is best to reduce the strong correlation between internal objects and config.GetGlobalConfig().

config/config.go Outdated Show resolved Hide resolved
@YuJuncen
Copy link
Contributor Author

/run-all-tests

@YuJuncen
Copy link
Contributor Author

That is strange... It fails but I cannot find any useful information about why it fails... Let me retry it.

/run-all-tests

@YuJuncen YuJuncen requested a review from zimulala July 3, 2020 03:11
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 7, 2020
@ti-srebot
Copy link
Contributor

@zimulala,Thanks for your review.

@YuJuncen
Copy link
Contributor Author

YuJuncen commented Jul 8, 2020

@breeswish PTAL~

@YuJuncen
Copy link
Contributor Author

/run-all-tests

[...137 lines of PASS]
[2020-07-14T02:46:35.115Z] FAIL	github.com/pingcap/tidb/ddl	17.459s

...Why? 🤔

@YuJuncen
Copy link
Contributor Author

/run-common-test

[2020-07-14T02:55:27.258Z] time="2020-07-14T10:55:27+08:00" level=fatal msg="run test [insert_select] err: sql:insert into t1 values (1,1);: run \"insert into t1 values (1,1);\" at line 126 err Error 1146: Table 'test.t1' doesn't exist"

....

@YuJuncen
Copy link
Contributor Author

/run-common-test

[2020-07-14T03:04:45.669Z] [2020/07/14 11:04:25.160 +08:00] [ERROR] [main.go:215] ["The current temporary storage dir has been occupied by another instance, check tmp-storage-path config and make sure they are different."] [TempStoragePath="/tmp/1000_tidb/MC4wLjAuMDo0MDAxLzAuMC4wLjA6OTA4MQ==/tmp-storage"] [error="fslock: lock is held"] [stack="github.com/pingcap/log.Error\n\t/home/jenkins/agent/workspace/tidb_ghpr_build/go/pkg/mod/github.com/pingcap/log@v0.0.0-20200511115504-543df19646ad/global.go:42\nmain.initializeTempDir\n\t/home/jenkins/agent/workspace/tidb_ghpr_build/go/src/github.com/pingcap/tidb/tidb-server/main.go:215\nmain.main\n\t/home/jenkins/agent/workspace/tidb_ghpr_build/go/src/github.com/pingcap/tidb/tidb-server/main.go:172\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:203"]

We died at different place each time 🙃...

@YuJuncen
Copy link
Contributor Author

/run-unit-test

Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Jul 14, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 14, 2020
@YuJuncen
Copy link
Contributor Author

/merge

@ti-srebot
Copy link
Contributor

@YuJuncen Oops! auto merge is restricted to Committers of the SIG.See the corresponding SIG page for more information. Related SIGs: ddl(slack).

@crazycs520
Copy link
Contributor

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 14, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 07c6788 into pingcap:master Jul 14, 2020
YuJuncen added a commit to YuJuncen/tidb that referenced this pull request Jul 15, 2020
* domain,session: add NoRegister entry

* session: run fmt

* session: remove old NoRegister API

* config: add no register config

* config: add example to example config file.

* session: remove unused type

* *: rename NoRegister to SkipRegisterToDashboard

Co-authored-by: crazycs <crazycs520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/config sig/sql-infra SIG: SQL Infra 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.

BR registers itself as TiDB
8 participants