Conversation
Codecov Report
@@ Coverage Diff @@
## master #111 +/- ##
==========================================
- Coverage 51.92% 50.56% -1.36%
==========================================
Files 17 17
Lines 1770 1780 +10
==========================================
- Hits 919 900 -19
- Misses 782 816 +34
+ Partials 69 64 -5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
v4/export/sql.go
Outdated
v = wrapQuotes(v) | ||
s := fmt.Sprintf("SET SESSION %s = %s", k, v) | ||
_, err := db.Exec(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v = wrapQuotes(v) | |
s := fmt.Sprintf("SET SESSION %s = %s", k, v) | |
_, err := db.Exec(s) | |
s := fmt.Sprintf("SET SESSION %s = ?", k) | |
_, err := db.Exec(s, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use this format at first, but at last this failed when I try to set tidb_mem_quota_query
.
[2020/06/30 18:39:05.433 +08:00] [ERROR] [main.go:191] ["dump failed error stack info"] [error="Error 1231: Variable 'tidb_mem_quota_query' can't be set to the value of '%!s(MISSING)'"] [errorVerbose="err = Error 1231: Variable 'tidb_mem_quota_query' can't be set to the value of '%!s(MISSING)'\ngoroutine 1 [running]:\nruntime/debug.Stack(0x19fc520, 0xc0001fc220, 0x19fd9e0)\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x9d\ngithub.com/pingcap/dumpling/v4/export.withStack(0x19fc520, 0xc0001fc220, 0xc000038000, 0xc000152570)\n\t/Users/chauncy/code/goPath/src/github.com/pingcap/dumpling/v4/export/error.go:59 +0x8d\ngithub.com/pingcap/dumpling/v4/export.resetDBWithSessionParams(0xc0001fe000, 0xc000152540, 0x2a, 0xc0001d2600, 0x2a, 0x0, 0x0)\n\t/Users/chauncy/code/goPath/src/github.com/pingcap/dumpling/v4/export/sql.go:389 +0x684\ngithub.com/pingcap/dumpling/v4/export.Dump(0x1a13400, 0xc000038090, 0xc00012cea0, 0x0, 0x0)\n\t/Users/chauncy/code/goPath/src/github.com/pingcap/dumpling/v4/export/dump.go:101 +0x327\nmain.main()\n\t/Users/chauncy/code/goPath/src/github.com/pingcap/dumpling/cmd/dumpling/main.go:189 +0x132f\n"] [stack="github.com/pingcap/log.Error\n\t/Users/chauncy/code/goPath/pkg/mod/github.com/pingcap/log@v0.0.0-20200511115504-543df19646ad/global.go:42\nmain.main\n\t/Users/chauncy/code/goPath/src/github.com/pingcap/dumpling/cmd/dumpling/main.go:191\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:203"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arguments:
Running command: ['/Users/chauncy/code/goPath/src/github.com/pingcap/dumpling/bin/dumpling', '-T', 'TICASE_3204_WTHYZC.dumpsnap', '--dump-empty-database=false', '--snapshot', '2020-06-30 18:39:03', '-h', '127.0.0.1', '-P', '4000', '-u', 'root', '-p', '', '-o', '/var/folders/sr/_hc37vmj0db6ht4_w6rw34880000gn/T/tmptv4miiea']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lichunzhu why is it %!s(MISSING)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kennytm Before db.Exec this variable's values is "34359738368"
. Maybe after translation it becomes %!s(MISSING)
.
v4/export/config.go
Outdated
@@ -53,7 +53,7 @@ type Config struct { | |||
FileType string | |||
EscapeBackslash bool | |||
DumpEmptyDatabase bool | |||
TiDBMemQuotaQuery uint64 | |||
SessionParams map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps this should be
SessionParams map[string]string | |
SessionParams map[string]interface{} |
so that we could assign a number to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we still have to transfer it to string for dsn 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…SnapshotProblem
…pling into fixSnapshotProblem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
v4/export/sql.go
Outdated
dsn += fmt.Sprintf("&%s=%s", k, url.QueryEscape(v)) | ||
var s string | ||
if str, ok := v.(string); ok { | ||
s = wrapQuotation(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just wrap the quotation mark directly. the only case the str
passes the strings.HasPrefix
stuff is when user invokes dumpling as
./dumpling --snapshot "'stuff'"
which is so unnatural that there's no point supporting it.
s = wrapQuotation(str) | |
s = wrapStringWith(str, "'") |
(the wrapBackTicks
function probably has the same bug, let's check it in the future)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@kennytm PTAL again |
* hotfix snapshot * update code * fix again * use session param to reset db after setup * address comment * address comment
* hotfix snapshot * update code * fix again * use session param to reset db after setup * address comment * address comment
* hotfix snapshot * update code * fix again * use session param to reset db after setup * address comment * address comment
* hotfix snapshot * update code * fix again * use session param to reset db after setup * address comment * address comment
* hotfix snapshot * update code * fix again * use session param to reset db after setup * address comment * address comment
What problem does this PR solve?
fix #112
db.Exec("set tidb_snapshot = ?")
to settidb_snapshot
, but this can only influence that connection. The connection pool'stidb_snapshot
is not set.set snapshot
, which means the fetched tables are not the tables we actually want. But for consistency "lock" it needs all tables to lock before the dump process.What is changed and how it works?
SessionParams
inconf
. After we adjust all theSessionParams
dumpling will resetsql.DB
with the new dsn. This can make sure all connections' session variable has been set.a. set snapshot ts into
session params
b. fetch all the tables.
c. set consistency.
Check List
Tests
Side effects
Related changes
Release note