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

support --max-idle-time argument #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion v4/export/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const (
flagCompleteInsert = "complete-insert"
flagParams = "params"
flagReadTimeout = "read-timeout"
flagMaxIdleTime = "max-idle-time"
flagTransactionalConsistency = "transactional-consistency"
flagCompress = "compress"

Expand Down Expand Up @@ -124,6 +125,7 @@ type Config struct {
OutputFileTemplate *template.Template `json:"-"`
Rows uint64
ReadTimeout time.Duration
MaxIdleTime time.Duration
TiDBMemQuotaQuery uint64
FileSize uint64
StatementSize uint64
Expand Down Expand Up @@ -242,7 +244,7 @@ func (conf *Config) DefineFlags(flags *pflag.FlagSet) {
flags.StringToString(flagParams, nil, `Extra session variables used while dumping, accepted format: --params "character_set_client=latin1,character_set_connection=latin1"`)
flags.Bool(FlagHelp, false, "Print help message and quit")
flags.Duration(flagReadTimeout, 15*time.Minute, "I/O read timeout for db connection.")
_ = flags.MarkHidden(flagReadTimeout)
flags.Duration(flagMaxIdleTime, 600*time.Second, "max idle time for db connection.")
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd better keep flagReadTimeout hidden. What's more, we'd better keep flagMaxIdleTime hidden, too. We can "un-hidden" these arguments if they are frequently used.

Copy link
Author

Choose a reason for hiding this comment

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

err... so those arguments still unseen to others, unless they look the source code?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can add these flags to official documents.

flags.Bool(flagTransactionalConsistency, true, "Only support transactional consistency")
_ = flags.MarkHidden(flagTransactionalConsistency)
flags.StringP(flagCompress, "c", "", "Compress output file type, support 'gzip', 'no-compression' now")
Expand Down Expand Up @@ -384,6 +386,10 @@ func (conf *Config) ParseFromFlags(flags *pflag.FlagSet) error {
if err != nil {
return errors.Trace(err)
}
conf.MaxIdleTime, err = flags.GetDuration(flagMaxIdleTime)
if err != nil {
return errors.Trace(err)
}
conf.TransactionalConsistency, err = flags.GetBool(flagTransactionalConsistency)
if err != nil {
return errors.Trace(err)
Expand Down
2 changes: 2 additions & 0 deletions v4/export/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ func openSQLDB(d *Dumper) error {
if err != nil {
return errors.Trace(err)
}
pool.SetConnMaxIdleTime(conf.MaxIdleTime)
d.dbHandle = pool
return nil
}
Expand Down Expand Up @@ -1155,5 +1156,6 @@ func setSessionParam(d *Dumper) error {
if d.dbHandle, err = resetDBWithSessionParams(d.tctx, pool, conf.GetDSN(""), conf.SessionParams); err != nil {
return errors.Trace(err)
}
d.dbHandle.SetConnMaxIdleTime(conf.MaxIdleTime)
return nil
}