# Table is locked during pt-osc and errors copying rows

**URL:** <https://forums.percona.com/t/table-is-locked-during-pt-osc-and-errors-copying-rows/6726>\
**Category:** Percona Toolkit\
**Created:** [December 6, 2018, 2:15am UTC](https://forums.percona.com/t/table-is-locked-during-pt-osc-and-errors-copying-rows/6726 "2018-12-06T02:15:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaiDuong92](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@DaiDuong92](https://forums.percona.com/u/DaiDuong92)\
**Post date:** [December 6, 2018, 2:15am UTC](https://forums.percona.com/t/table-is-locked-during-pt-osc-and-errors-copying-rows/6726/1 "2018-12-06T02:15:11Z")

</div>

I try to modify data type of a MySQL table using pt-osc:  
“pt-online-schema-change h=host\_name,D=database\_name,t=one\_time\_tokens,u=user\_name,p=password --alter “MODIFY COLUMN price\_per\_download decimal(10,2)” --execute”

1. During the alter process, I run this command in mysql many times:  
“show open tables where in\_use \> 0”  
The results intermittently shows locked tables:  
[TABLE=“border: 1, cellpadding: 1, width: 500”]  
[TR]  
[TD]Database[/TD]  
[TD]Table[/TD]  
[TD]In\_use[/TD]  
[TD]Name\_locked[/TD]  
[/TR]  
[TR]  
[TD]Database\_name[/TD]  
[TD]one\_time\_tokens[/TD]  
[TD]1[/TD]  
[TD]0[/TD]  
[/TR]  
[TR]  
[TD]Database\_name[/TD]  
[TD]\_one\_time\_tokens\_new[/TD]  
[TD]1[/TD]  
[TD]0[/TD]  
[/TR]  
[/TABLE]

(sometimes it shows this table, sometimes it shows empty set)  
Does it mean that my table is still locked during table alter?

1. The operation fails to copy rows from old table to new table. Here is the log:

Operation, tries, wait:  
analyze\_table, 10, 1  
copy\_rows, 10, 0.25  
create\_triggers, 10, 1  
drop\_triggers, 10, 1  
swap\_tables, 10, 1  
update\_foreign\_keys, 10, 1  
Altering `database_name`.`one_time_tokens`…  
Creating new table…  
Created new table database\_name.\_one\_time\_tokens\_new OK.  
Altering new table…  
Altered `database_name`.`_one_time_tokens_new` OK.  
2018-12-06T13:52:31 Creating triggers…  
2018-12-06T13:52:31 Created triggers OK.  
2018-12-06T13:52:32 Copying approximately 8977540 rows…  
2018-12-06T13:53:02 Dropping triggers…  
2018-12-06T13:53:02 Dropped triggers OK.  
2018-12-06T13:53:02 Dropping new table…  
2018-12-06T13:53:03 Dropped new table OK.  
`database_name`.`one_time_tokens` was not altered.  
2018-12-06T13:53:02 Error copying rows from `database_name`.`one_time_tokens` to `database_name`.`_one_time_tokens_new`: Redundant argument in printf at /usr/bin/pt-online-schema-change line 3595 of

Here is what is see in the line 3595 of /usr/bin/pt-online-schema-change

printf STDERR “$name: %3d%% %s remain\n”,  
$fraction \* 100,  
Transformers::secs\_to\_time($remaining),  
Transformers::ts($eta);

Is it an error in percona-toolkit’s source code ? Or what else can be the root cause of this failure to copy?

---

<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:** [December 12, 2018, 10:34am UTC](https://forums.percona.com/t/table-is-locked-during-pt-osc-and-errors-copying-rows/6726/2 "2018-12-12T10:34:53Z")

</div>

Hi,

It’s seems like you are using a modified version of pt-online-schema-change.  
At lines [url][percona-toolkit/pt-online-schema-change at 3.0 · percona/percona-toolkit · GitHub](https://github.com/percona/percona-toolkit/blob/3.0/bin/pt-online-schema-change#L3674-L3676%5B/url%5D), the code is:

```auto
printf STDERR "$name: %3d%% %s remain\n",
$fraction * 100,
Transformers::secs_to_time($remaining);

```

and you have an extra parameter there.

Regards
