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

Add conn session vars #265

Merged
merged 2 commits into from Apr 5, 2021
Merged

Conversation

recall704
Copy link
Contributor

@recall704 recall704 commented Apr 2, 2021

What problem does this PR solve?

fix resetDBWithSessionParams if value is int or float

What is changed and how it works?

try to parse params values string to int or float.

@lichunzhu
Copy link
Contributor

lichunzhu commented Apr 2, 2021

@recall704 What's the difference between this and params introduced in #111 and #167?

@recall704
Copy link
Contributor Author

#!/bin/bash

HOST="127.0.0.1"
PORT=3306
USER="root"
PSW="mypasswd"
DATA_DIR="data2"

rm rf -$DATA_DIR && mkdir -p $DATA_DIR

./bin/dumpling \
    --host=$HOST \
    --port=$PORT \
    --user=$USER \
    --password=$PSW \
    --logfmt=json \
    --loglevel=debug \
    --filter="*.*,!/^(mysql|sys|grafana_ucloud|INFORMATION_SCHEMA|PERFORMANCE_SCHEMA|METRICS_SCHEMA|INSPECTION_SCHEMA)$/.*" \
    --threads=16 \
    --status-addr=:8281 \
    --output=$DATA_DIR \
    --filetype=sql \
    --rows=100000 \
    --params="net_read_timeout=86400,interactive_timeout=28800,wait_timeout=2147483,net_write_timeout=86400" \
    --tidb-mem-quota-query=35433480192

the erorr is

dump failed: Error 1232: Incorrect argument type to variable 'wait_timeout'

you set the session vars with db.ExecContext,

		s := fmt.Sprintf("SET SESSION %s = ?", k)
		_, err := db.ExecContext(tctx, s, v)

and i set the session vars with conn.ExecContext

		query := fmt.Sprintf("SET SESSION %s = %s", k, s)
		_, err := conn.ExecContext(tctx, query)

@lichunzhu
Copy link
Contributor

#!/bin/bash

HOST="127.0.0.1"
PORT=3306
USER="root"
PSW="mypasswd"
DATA_DIR="data2"

rm rf -$DATA_DIR && mkdir -p $DATA_DIR

./bin/dumpling \
    --host=$HOST \
    --port=$PORT \
    --user=$USER \
    --password=$PSW \
    --logfmt=json \
    --loglevel=debug \
    --filter="*.*,!/^(mysql|sys|grafana_ucloud|INFORMATION_SCHEMA|PERFORMANCE_SCHEMA|METRICS_SCHEMA|INSPECTION_SCHEMA)$/.*" \
    --threads=16 \
    --status-addr=:8281 \
    --output=$DATA_DIR \
    --filetype=sql \
    --rows=100000 \
    --params="net_read_timeout=86400,interactive_timeout=28800,wait_timeout=2147483,net_write_timeout=86400" \
    --tidb-mem-quota-query=35433480192

the erorr is

dump failed: Error 1232: Incorrect argument type to variable 'wait_timeout'

you set the session vars with db.ExecContext,

		s := fmt.Sprintf("SET SESSION %s = ?", k)
		_, err := db.ExecContext(tctx, s, v)

and i set the session vars with conn.ExecContext

		query := fmt.Sprintf("SET SESSION %s = %s", k, s)
		_, err := conn.ExecContext(tctx, query)

Yes. dumpling will return an error. I think maybe fixing --params is enough. Could you please explain why do you want to add another argument --session-params?

@recall704
Copy link
Contributor Author

#!/bin/bash

HOST="127.0.0.1"
PORT=3306
USER="root"
PSW="mypasswd"
DATA_DIR="data2"

rm rf -$DATA_DIR && mkdir -p $DATA_DIR

./bin/dumpling \
    --host=$HOST \
    --port=$PORT \
    --user=$USER \
    --password=$PSW \
    --logfmt=json \
    --loglevel=debug \
    --filter="*.*,!/^(mysql|sys|grafana_ucloud|INFORMATION_SCHEMA|PERFORMANCE_SCHEMA|METRICS_SCHEMA|INSPECTION_SCHEMA)$/.*" \
    --threads=16 \
    --status-addr=:8281 \
    --output=$DATA_DIR \
    --filetype=sql \
    --rows=100000 \
    --params="net_read_timeout=86400,interactive_timeout=28800,wait_timeout=2147483,net_write_timeout=86400" \
    --tidb-mem-quota-query=35433480192

the erorr is

dump failed: Error 1232: Incorrect argument type to variable 'wait_timeout'

you set the session vars with db.ExecContext,

		s := fmt.Sprintf("SET SESSION %s = ?", k)
		_, err := db.ExecContext(tctx, s, v)

and i set the session vars with conn.ExecContext

		query := fmt.Sprintf("SET SESSION %s = %s", k, s)
		_, err := conn.ExecContext(tctx, query)

Yes. dumpling will return an error. I think maybe fixing --params is enough. Could you please explain why do you want to add another argument --session-params?

OK, I will try to fix in --params

@recall704
Copy link
Contributor Author

@lichunzhu It's works now

image

@lichunzhu
Copy link
Contributor

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lichunzhu

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.

@ti-chi-bot ti-chi-bot added the status/LGT1 One reviewer approved (LGTM1) label Apr 5, 2021
@lichunzhu
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 304f26c

@lichunzhu
Copy link
Contributor

LGTM. Thanks for your contribution!

@ti-chi-bot ti-chi-bot merged commit 59b763e into pingcap:master Apr 5, 2021
lichunzhu pushed a commit to lichunzhu/dumpling that referenced this pull request Apr 14, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/tidb that referenced this pull request Oct 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/S status/can-merge status/LGT1 One reviewer approved (LGTM1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants