Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

worker: use random value as server-id if server-id is not set #329

Merged
merged 32 commits into from
Oct 25, 2019
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3f9b12a
use random server-id if not set
WangXiangUSTC Oct 21, 2019
6b1ee0a
remove server-id in integration test
WangXiangUSTC Oct 21, 2019
177dbdf
add unit test for get slave hosts
WangXiangUSTC Oct 21, 2019
ce20637
add unit test for config
WangXiangUSTC Oct 21, 2019
8b8453c
remove useless code
WangXiangUSTC Oct 21, 2019
2474fe0
update variable name
WangXiangUSTC Oct 21, 2019
2a1e83c
Merge branch 'master' into xiang/server_id
csuzhangxc Oct 22, 2019
394d4c2
address comment
WangXiangUSTC Oct 22, 2019
d14bd4c
minor update
WangXiangUSTC Oct 22, 2019
84efa8c
fix function name
WangXiangUSTC Oct 22, 2019
b389461
Update dm/worker/config.go
WangXiangUSTC Oct 22, 2019
4830291
address comment
WangXiangUSTC Oct 22, 2019
38f6c59
Merge branch 'xiang/server_id' of https://github.com/pingcap/dm into …
WangXiangUSTC Oct 22, 2019
457bbbf
change server id to uint32
WangXiangUSTC Oct 22, 2019
ec9bb07
fix
WangXiangUSTC Oct 22, 2019
3fb9a44
update comment
WangXiangUSTC Oct 22, 2019
e668f68
address comnemnt
WangXiangUSTC Oct 22, 2019
0c4b592
fix test
WangXiangUSTC Oct 22, 2019
7d0f754
format code
WangXiangUSTC Oct 22, 2019
3bc5c5f
fix test
WangXiangUSTC Oct 22, 2019
3aedf77
Merge branch 'master' into xiang/server_id
WangXiangUSTC Oct 23, 2019
0a4ce74
fix test
WangXiangUSTC Oct 23, 2019
aa2b214
Merge branch 'xiang/server_id' of https://github.com/pingcap/dm into …
WangXiangUSTC Oct 23, 2019
02a6fcb
resolve conflit
WangXiangUSTC Oct 23, 2019
6ca9c90
address comment
WangXiangUSTC Oct 23, 2019
898754f
add rand seed
WangXiangUSTC Oct 23, 2019
69ca67e
fix unit for heartbeat
WangXiangUSTC Oct 23, 2019
7b923f4
fix heartbeat
WangXiangUSTC Oct 23, 2019
5bbc661
fix
WangXiangUSTC Oct 23, 2019
354a2fc
address comment
WangXiangUSTC Oct 25, 2019
b1a8fbd
address comment
WangXiangUSTC Oct 25, 2019
9b89300
address comemnt
WangXiangUSTC Oct 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions dm/worker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
// flavorGetTimeout is timeout for getting some information from DB
csuzhangxc marked this conversation as resolved.
Show resolved Hide resolved
dbGetTimeout = 30 * time.Second

maxServerID = 4294967295
maxServerID = 1<<32 - 1
)

// SampleConfigFile is sample config file of dm-worker
Expand Down Expand Up @@ -264,23 +264,27 @@ func (c *Config) adjust() error {
c.From.Adjust()
c.Checker.adjust()

fromDB, err := c.createBaseDB()
if err != nil {
return err
}
defer fromDB.Close()
if c.Flavor == "" || c.ServerID == 0 {
return nil
csuzhangxc marked this conversation as resolved.
Show resolved Hide resolved

ctx, cancel := context.WithTimeout(context.Background(), dbGetTimeout)
defer cancel()
fromDB, err := c.createBaseDB()
if err != nil {
return err
}
defer fromDB.Close()

err = c.adjustFlavor(ctx, fromDB.DB)
if err != nil {
return err
}
ctx, cancel := context.WithTimeout(context.Background(), dbGetTimeout)
defer cancel()

err = c.adjustServerID(ctx, fromDB.DB)
if err != nil {
return err
err = c.adjustFlavor(ctx, fromDB.DB)
if err != nil {
return err
}

err = c.adjustServerID(ctx, fromDB.DB)
if err != nil {
return err
}
}

return nil
Expand Down