pt-archiver "a" option for "use" database doesn't work
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
If you use the "a" option in your DSN, it will correctly USE the database, however later, when TableParser runs, it will 'USE' the original database again, in get_create_table.
Version: 2.2.7
MySQL version: Server version: 5.1.49-
I ran:
PTDEBUG=1 ./pt-archiver --source h=10.10.
There's no debug output for the USE on line 5619, so the output doesn't actually show them both happening, and which order they were in, however it does output:
# $DBD::mysql:
# pt_archiver:5614 23048 Inspecting table on D=carrierwebus,
# VersionParser:2771 23048 VersionParser got a dbh, trying to get the version
# VersionParser:2819 23048 InnoDB support: NO
# VersionParser:2831 23048 InnoDB version: NO
# TableParser:1874 23048 /*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := '', @OLD_QUOTE := @@SQL_QUOTE_
# TableParser:1879 23048 DBI::db=
# TableParser:1883 23048 SHOW CREATE TABLE `carrierwebus`
# TableParser:1893 23048 /*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, @@SQL_QUOTE_
# TableParser:2071 23048 Storage engine: MyISAM
# TableParser:1925 23048 Table cols: `nid`, `nvehicleid`, `ncustomerid`, `nroutegeofenceid`, `tmevent`, `bcode`
# TableParser:2071 23048 Storage engine: MyISAM
# TableParser:2087 23048 Parsed key: PRIMARY KEY (`nid`),
# TableParser:2107 23048 PRIMARY key cols: `nid`
# TableParser:2087 23048 Parsed key: KEY `nvehicleid_
# TableParser:2107 23048 nvehicleid_tmevent key cols: `nvehicleid`, `tmevent`
# TableParser:2087 23048 Parsed key: KEY `ncustomerid_nid` (`ncustomerid`
# TableParser:2107 23048 ncustomerid_nid key cols: `ncustomerid`, `nid`
# pt_archiver:5660 23048 SELECT CONCAT(/*!40100 @@session.
# pt_archiver:5750 23048 sel cols: nid nvehicleid ncustomerid nroutegeofenceid tmevent bcode
# TableParser:1986 23048 Indexes sorted best-first: PRIMARY, ncustomerid_nid, nvehicleid_tmevent
# TableParser:2004 23048 Best index found is PRIMARY
# TableNibbler:3183 23048 Columns needed for DELETE: nid
# TableNibbler:3193 23048 Ordinals needed for DELETE: 0
# TableNibbler:3039 23048 Will ascend index PRIMARY
# TableNibbler:3051 23048 Will ascend columns nid
# TableNibbler:3062 23048 Will ascend, in ordinal position: 0
# VersionParser:2771 23048 VersionParser got a dbh, trying to get the version
# VersionParser:2819 23048 InnoDB support: NO
# VersionParser:2831 23048 InnoDB version: NO
# pt_archiver:5824 23048 Index for DELETE: PRIMARY
# pt_archiver:5838 23048 DELETE index is unique; LIMIT 1 is not needed
# pt_archiver:5904 23048 get first sql: SELECT /*!40001 SQL_NO_CACHE */ `nid`,`
# pt_archiver:5905 23048 get next sql: SELECT /*!40001 SQL_NO_CACHE */ `nid`,`
# pt_archiver:5906 23048 del row sql: DELETE FROM `carrierwebus`
# pt_archiver:5907 23048 ins row sql:
SELECT /*!40001 SQL_NO_CACHE */ `nid`,`
SELECT /*!40001 SQL_NO_CACHE */ `nid`,`
DELETE FROM `carrierwebus`
Which includes the errant "USE" on line 1879, in TableParser. As far as I can tell, removing that USE will fix it.
--- pt-archiver.orig 2014-02-28 17:11:49.000000000 +0000
+++ pt-archiver 2014-02-28 17:11:56.000000000 +0000
@@ -1875,10 +1875,6 @@
eval { $dbh->do(
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
- my $use_sql = 'USE ' . $q->quote($db);
- PTDEBUG && _d($dbh, $use_sql);
- $dbh->do($use_sql);
-
my $show_sql = "SHOW CREATE TABLE " . $q->quote($db, $tbl);
PTDEBUG && _d($show_sql);
my $href;
tags: | added: pt-archiver |
I am able to reproduce this problem. option 'a' seems to be broken.
$ pt-archiver --version
pt-archiver 2.2.7
$ PTDEBUG=1 pt-archiver --source h=localhost, D=world, a=test, t=City, u=msandbox, p=msandbox -S /tmp/mysql_ sandbox5616. sock --where "ID<4000" --purge --progress 1000 > archive.log 2>&1
# /usr/bin/perl 5.010001 279.el6. x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux D=world, a=test, t=City, u=msandbox, p=msandbox] _ _[-S]_ _[/tmp/ mysql_sandbox56 16.sock] _ _[--where]_ _[ID<4000]_ _[--purge]_ _[--progress]_ _[1000]_ SHOW_CREATE, @@SQL_QUOTE_ SHOW_CREATE := 1 */ HASH(0x2120850) USE `world` SHOW_CREATE := @OLD_QUOTE */
# Linux centos63 2.6.32-
# Arguments: _[--source]_ _[h=localhost,
# OptionParser:927 2087 Option rule: Specify at least one of --dest, --file, or --purge.
.
.
# TableParser:1874 2087 /*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := '', @OLD_QUOTE := @@SQL_QUOTE_
# TableParser:1879 2087 DBI::db=
# TableParser:1883 2087 SHOW CREATE TABLE `world`.`City`
# TableParser:1893 2087 /*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, @@SQL_QUOTE_
# TableParser:2071 2087 Storage engine: InnoDB