# Use of uninitialized value in join or string at /bin/pt-online-schema-change

**URL:** <https://forums.percona.com/t/use-of-uninitialized-value-in-join-or-string-at-bin-pt-online-schema-change/6397>\
**Category:** Percona Toolkit\
**Created:** [June 4, 2018, 7:37am UTC](https://forums.percona.com/t/use-of-uninitialized-value-in-join-or-string-at-bin-pt-online-schema-change/6397 "2018-06-04T07:37:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarwin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/tarwin/32/1226_2.png) [@tarwin](https://forums.percona.com/u/tarwin)\
**Post date:** [June 4, 2018, 7:37am UTC](https://forums.percona.com/t/use-of-uninitialized-value-in-join-or-string-at-bin-pt-online-schema-change/6397/1 "2018-06-04T07:37:37Z")

</div>

Hi everybody

we are trying to apply migrations to a small forum database but sadly get confusing error messages.

Database:  
percona xtradb - 5.7.16-10-57-log on Centos 7.4

The table:  
±-----------------±-------------±-----±----±--------±------+  
| Field | Type | Null | Key | Default | Extra |  
±-----------------±-------------±-----±----±--------±------+  
| conversationID | int(10) | NO | MUL | NULL | |  
| participantID | int(10) | YES | MUL | NULL | |  
| username | varchar(255) | NO | | | |  
| hideConversation | tinyint(1) | NO | | 0 | |  
| isInvisible | tinyint(1) | NO | | 0 | |  
| lastVisitTime | int(10) | NO | | 0 | |  
| joinedAt | int(10) | NO | | 0 | |  
| leftAt | int(10) | NO | | 0 | |  
| lastMessageID | int(10) | YES | MUL | NULL | |  
±-----------------±-------------±-----±----±--------±------+

The original query:  
ALTER TABLE wcf1\_conversation\_to\_user ADD COLUMN conversationToUserID INT(10) UNSIGNED PRIMARY KEY AUTO\_INCREMENT;

That should work:  
PTDEBUG=1 pt-online-schema-change --execute “ADD COLUMN conversationToUserID INT(10) UNSIGNED PRIMARY KEY AUTO\_INCREMENT” D=board\_wcf,t=wcf1\_conversation\_to\_user

But doesnt:  
\<snip lots of seemingly unimportend stuff to get under the 10000 char limit\>

# /usr/bin/perl 5.016003

# Linux exampledb01.not.real 3.10.0-693.21.1.el7.x86\_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86\_64 x86\_64 x86\_64 GNU/Linux

# Arguments: _[–execute]_ _[–alter]_ _[ADD COLUMN conversationToUserID INT(10) UNSIGNED PRIMARY KEY AUTO\_INCREMENT]_ _[D=board\_wcf,t=wcf1\_conversation\_to\_user]_

…

# NibbleIterator:5971 11747 EXPLAIN SELECT \* FROM `board_wcf`.`wcf1_conversation_to_user` WHERE 1=1

# NibbleIterator:5973 11747 $VAR1 = {

# extra =\> undef,

# filtered =\> ‘100.00’,

# id =\> ‘1’,

# key =\> undef,

# key\_len =\> undef,

# partitions =\> undef,

# possible\_keys =\> undef,

# ref =\> undef,

# rows =\> ‘6059’,

# select\_type =\> ‘SIMPLE’,

# table =\> ‘wcf1\_conversation\_to\_user’,

# type =\> ‘ALL’

# };

…

# NibbleIterator:5521 11747 Ascend params: $VAR1 = {

# boundaries =\> {

# ‘\<’ =\> ‘((((? IS NOT NULL AND `participantid` IS NULL) OR (`participantid` \< ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \< ?))’,

# ‘\<=’ =\> ‘((((? IS NOT NULL AND `participantid` IS NULL) OR (`participantid` \< ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \<= ?))’,

# ‘\>’ =\> ‘((((? IS NULL AND `participantid` IS NOT NULL) OR (`participantid` \> ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \> ?))’,

# ‘\>=’ =\> ‘((((? IS NULL AND `participantid` IS NOT NULL) OR (`participantid` \> ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \>= ?))’

# },

# cols =\> [

# ‘conversationid’,

# ‘participantid’,

# ‘username’,

# ‘hideconversation’,

# ‘isinvisible’,

# ‘lastvisittime’,

# ‘joinedat’,

# ‘leftat’,

# ‘lastmessageid’

# ],

# index =\> ‘participantid’,

# scols =\> [

# ‘participantid’,

# ‘participantid’,

# ‘participantid’,

# ‘participantid’,

# ‘conversationid’

# ],

# slice =\> [

# 1,

# 1,

# 1,

# 1,

# 0

# ],

# where =\> ‘((((? IS NULL AND `participantid` IS NOT NULL) OR (`participantid` \> ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \> ?))’

# };

# 

# NibbleIterator:5538 11747 First lower boundary statement: SELECT /\*!40001 SQL\_NO\_CACHE \*/ `participantid`, `participantid`, `participantid`, `participantid`, `conversationid` FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX(`participantid`) ORDER BY `participantid`, `conversationid` LIMIT 1 /_first lower boundary_/

# NibbleIterator:5563 11747 Last upper boundary statement: SELECT /\*!40001 SQL\_NO\_CACHE \*/ `participantid`, `participantid`, `participantid`, `participantid`, `conversationid` FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX(`participantid`) ORDER BY `participantid` DESC,`conversationid` DESC LIMIT 1 /_last upper boundary_/

# NibbleIterator:5574 11747 Upper boundary statement: SELECT /\*!40001 SQL\_NO\_CACHE \*/ `participantid`, `participantid`, `participantid`, `participantid`, `conversationid` FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX(`participantid`) WHERE ((((? IS NULL AND `participantid` IS NOT NULL) OR (`participantid` \> ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \>= ?)) ORDER BY `participantid`, `conversationid` LIMIT ?, 2 /_next chunk boundary_/

…

# NibbleIterator:5603 11747 Initial chunk size (LIMIT): 999

# NibbleIterator:5983 11747 Preparing statement handles

# NibbleIterator:6012 11747 First lower boundary: $VAR1 = [

# undef,

# undef,

# undef,

# undef,

# ‘1’

# ];

# 

# NibbleIterator:6028 11747 Next lower boundary: $VAR1 = [

# undef,

# undef,

# undef,

# undef,

# ‘1’

# ];

# 

2018-06-04T13:07:38 Copying approximately 6059 rows…

# IndexLength:6678 11747 SELECT /\*!40001 SQL\_NO\_CACHE \*/ `participantid`, `conversationid` FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX (`participantid`) WHERE `participantid` IS NOT NULL AND `conversationid` IS NOT NULL ORDER BY `participantid`, `conversationid` LIMIT 1 /_key\_len_/

# IndexLength:6645 11747 EXPLAIN SELECT /\*!40001 SQL\_NO\_CACHE \*/ \* FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX (`participantid`) WHERE `participantid` = ? AND `conversationid` \>= ? /_key\_len_/ params: 1 1

# IndexLength:6649 11747 Range scan: $VAR1 = {

# extra =\> ‘Using index condition’,

# filtered =\> ‘100.00’,

# id =\> ‘1’,

# key =\> ‘participantID’,

# key\_len =\> ‘9’,

# partitions =\> undef,

# possible\_keys =\> ‘participantID’,

# ref =\> undef,

# rows =\> ‘8’,

# select\_type =\> ‘SIMPLE’,

# table =\> ‘wcf1\_conversation\_to\_user’,

# type =\> ‘range’

# };

# 

# NibbleIterator:5657 11747 init callback returned 1

# pt\_online\_schema\_change:11489 11747 EXPLAIN SELECT /\*!40001 SQL\_NO\_CACHE \*/ `participantid`, `participantid`, `participantid`, `participantid`, `conversationid` FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX(`participantid`) WHERE ((((? IS NULL AND `participantid` IS NOT NULL) OR (`participantid` \> ?))) OR (((? IS NULL AND `participantid` IS NULL) OR (`participantid` = ?)) AND `conversationid` \>= ?)) ORDER BY `participantid`, `conversationid` LIMIT ?, 2 /_next chunk boundary_/ params: undef undef undef undef 1 999

# pt\_online\_schema\_change:11498 11747 EXPLAIN plan: $VAR1 = {

# extra =\> ‘Using where; Using index’,

# filtered =\> ‘100.00’,

# id =\> ‘1’,

# key =\> ‘participantID’,

# key\_len =\> ‘9’,

# partitions =\> undef,

# possible\_keys =\> ‘participantID’,

# ref =\> undef,

# rows =\> ‘3236’,

# select\_type =\> ‘SIMPLE’,

# table =\> ‘wcf1\_conversation\_to\_user’,

# type =\> ‘range’

# };

# 

# NibbleIterator:6083 11747 next\_boundaries callback returned 1

# CleanupTask:6551 11747 Calling cleanup task CODE(0x3159090)

…  
2018-06-04T13:07:38 Error copying rows from `board_wcf`.`wcf1_conversation_to_user` to `board_wcf`.`_wcf1_conversation_to_user_new`: Use of uninitialized value in join or string at /bin/pt-online-schema-change line 6092.

…

# Cxn:4096 11747 Destroying cxn

# Cxn:4105 11747 DBI::db=HASH(0x3091470) Disconnecting dbh on exampledb01.not.real

* * *

It seems the script stumbles over the ‘undefined’ results from the boundry queries:

Query:  
SELECT /\*!40001 SQL\_NO\_CACHE \*/ `participantid`, `participantid`, `participantid`, `participantid`, `conversationid` FROM `board_wcf`.`wcf1_conversation_to_user` FORCE INDEX(`participantid`) ORDER BY `participantid`, `conversationid` LIMIT 1  
Result:  
$VAR1 = [

# undef,

# undef,

# undef,

# undef,

# ‘1’

# ];

But we don’t really know what to do with this information.  
We tried with Percona toolkit 2.2.10 and 3.0.10, same problem.

Does anyone has an idea whats amiss?

Thanks  
Tarwin

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [June 4, 2018, 7:27pm UTC](https://forums.percona.com/t/use-of-uninitialized-value-in-join-or-string-at-bin-pt-online-schema-change/6397/2 "2018-06-04T19:27:42Z")

</div>

Hi,

Can you share the output of a SHOW CREATE TABLE board\_wcf.wcf1\_conversation\_to\_user ?

---

<div class="post-metadata">

**Author:** ![tarwin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/tarwin/32/1226_2.png) [@tarwin](https://forums.percona.com/u/tarwin)\
**Post date:** [June 5, 2018, 2:49am UTC](https://forums.percona.com/t/use-of-uninitialized-value-in-join-or-string-at-bin-pt-online-schema-change/6397/3 "2018-06-05T02:49:03Z")

</div>

Yes I can. =)

> SHOW CREATE TABLE board\_wcf.wcf1\_conversation\_to\_user  
> ±--------------------------±----------------------------------------------------------------------------------------------------------------------------------------------------------+  
> | Table | Create Table |  
> ±--------------------------±----------------------------------------------------------------------------------------------------------------------------------------------------------+  
> | wcf1\_conversation\_to\_user | CREATE TABLE `wcf1_conversation_to_user` ( |  
> | | `conversationID` int(10) NOT NULL, |  
> | | `participantID` int(10) DEFAULT NULL, |  
> | | `username` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL DEFAULT ‘’, |  
> | | `hideConversation` tinyint(1) NOT NULL DEFAULT ‘0’, |  
> | | `isInvisible` tinyint(1) NOT NULL DEFAULT ‘0’, |  
> | | `lastVisitTime` int(10) NOT NULL DEFAULT ‘0’, |  
> | | `joinedAt` int(10) NOT NULL DEFAULT ‘0’, |  
> | | `leftAt` int(10) NOT NULL DEFAULT ‘0’, |  
> | | `lastMessageID` int(10) DEFAULT NULL, |  
> | | UNIQUE KEY `participantID` (`participantID`,`conversationID`), |  
> | | KEY `participantID_2` (`participantID`,`hideConversation`), |  
> | | KEY `01e53cf51b570bae4ddcae0a765ea835_fk` (`conversationID`), |  
> | | KEY `befb99cae7d8abd731273eace0406910_fk` (`lastMessageID`), |  
> | | CONSTRAINT `01e53cf51b570bae4ddcae0a765ea835_fk` FOREIGN KEY (`conversationID`) REFERENCES `wcf1_conversation` (`conversationID`) ON DELETE CASCADE, |  
> | | CONSTRAINT `befb99cae7d8abd731273eace0406910_fk` FOREIGN KEY (`lastMessageID`) REFERENCES `wcf1_conversation_message` (`messageID`) ON DELETE SET NULL, |  
> | | CONSTRAINT `d52ac392b78c38925600cb02426d7af4_fk` FOREIGN KEY (`participantID`) REFERENCES `wcf1_user` (`userID`) ON DELETE SET NULL |  
> | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci |  
> ±--------------------------±----------------------------------------------------------------------------------------------------------------------------------------------------------+  
> 1 row in set  
> Time: 0.008s

> show index from board\_wcf.wcf1\_conversation\_to\_user  
> ±--------------------------±-----------±------------------------------------±-------------±-----------------±----------±------------±---------±-------±-----±-----------±--------±--------------+  
> | Table | Non\_unique | Key\_name | Seq\_in\_index | Column\_name | Collation | Cardinality | Sub\_part | Packed | Null | Index\_type | Comment | Index\_comment |  
> ±--------------------------±-----------±------------------------------------±-------------±-----------------±----------±------------±---------±-------±-----±-----------±--------±--------------+  
> | wcf1\_conversation\_to\_user | 0 | participantID | 1 | participantID | A | 3242 | | | YES | BTREE | | |  
> | wcf1\_conversation\_to\_user | 0 | participantID | 2 | conversationID | A | 5965 | | | | BTREE | | |  
> | wcf1\_conversation\_to\_user | 1 | participantID\_2 | 1 | participantID | A | 3242 | | | YES | BTREE | | |  
> | wcf1\_conversation\_to\_user | 1 | participantID\_2 | 2 | hideConversation | A | 3258 | | | | BTREE | | |  
> | wcf1\_conversation\_to\_user | 1 | 01e53cf51b570bae4ddcae0a765ea835\_fk | 1 | conversationID | A | 2737 | | | | BTREE | | |  
> | wcf1\_conversation\_to\_user | 1 | befb99cae7d8abd731273eace0406910\_fk | 1 | lastMessageID | A | 1 | | | YES | BTREE | | |  
> ±--------------------------±-----------±------------------------------------±-------------±-----------------±----------±------------±---------±-------±-----±-----------±--------±--------------+  
> 6 rows in set  
> Time: 0.010s
