square / square/shift

Patch failed for latest pt-online-schema-change

Open
#57 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
737
Forks
52
Avg merge
4d 4h
Merged PRs (30d)
1

Description

Patch command is getting failed while applying the patch file for the latest percona toolkit (3.0.13).

Logs:

root@localhost:/opt/shift/files# patch 3.0 ptosc-patch/0001-ptosc-square-changes.patch 
patching file 3.0
Hunk #1 succeeded at 28 (offset 1 line).
Hunk #2 succeeded at 3701 (offset 157 lines).
Hunk #3 succeeded at 3787 (offset 157 lines).
Hunk #4 succeeded at 5728 (offset 346 lines).
Hunk #5 succeeded at 5743 (offset 346 lines).
Hunk #6 succeeded at 5864 (offset 365 lines).
Hunk #7 succeeded at 6089 (offset 372 lines).
Hunk #8 succeeded at 6101 (offset 372 lines).
Hunk #9 succeeded at 8358 with fuzz 1 (offset 253 lines).
Hunk #10 succeeded at 8956 (offset 365 lines).
Hunk #11 succeeded at 9191 (offset 371 lines).
Hunk #12 succeeded at 9223 (offset 371 lines).
Hunk #13 succeeded at 9257 (offset 371 lines).
Hunk #14 succeeded at 9349 (offset 371 lines).
Hunk #15 succeeded at 9471 (offset 371 lines).
Hunk #16 succeeded at 9513 (offset 371 lines).
Hunk #17 succeeded at 9538 (offset 371 lines).
Hunk #18 succeeded at 9560 (offset 371 lines).
Hunk #19 succeeded at 9578 (offset 371 lines).
Hunk #20 succeeded at 9770 (offset 371 lines).
Hunk #21 succeeded at 9806 (offset 371 lines).
Hunk #22 succeeded at 9912 (offset 381 lines).
Hunk #23 succeeded at 9940 (offset 381 lines).
Hunk #24 succeeded at 9962 (offset 381 lines).
Hunk #25 succeeded at 10006 (offset 381 lines).
Hunk #26 succeeded at 10195 (offset 424 lines).
Hunk #27 succeeded at 10236 (offset 424 lines).
Hunk #28 succeeded at 10251 (offset 424 lines).
Hunk #29 succeeded at 10641 (offset 505 lines).
Hunk #30 succeeded at 10656 (offset 505 lines).
Hunk #31 FAILED at 10256.
Hunk #32 succeeded at 10860 (offset 568 lines).
Hunk #33 succeeded at 10882 (offset 566 lines).
Hunk #34 succeeded at 10911 (offset 566 lines).
Hunk #35 FAILED at 10359.
Hunk #36 succeeded at 11255 (offset 612 lines).
Hunk #37 FAILED at 10709.
Hunk #38 succeeded at 11684 (offset 773 lines).
Hunk #39 succeeded at 12460 (offset 842 lines).
Hunk #40 succeeded at 12537 (offset 879 lines).
Hunk #41 succeeded at 12569 with fuzz 2 (offset 891 lines).
Hunk #42 succeeded at 12691 with fuzz 2 (offset 944 lines).
Hunk #43 succeeded at 12843 with fuzz 2 (offset 993 lines).
Hunk #44 succeeded at 12914 with fuzz 2 (offset 1015 lines).
Hunk #45 succeeded at 12986 (offset 1016 lines).
3 out of 45 hunks FAILED -- saving rejects to file 3.0.rej

3.0.rej file:

--- pt-online-schema-change       2017-07-17 09:46:31.000000000 -0700
+++ pt-online-schema-change       2017-07-17 09:46:31.000000000 -0700
@@ -10256,6 +10583,16 @@
    elsif ( $o->get('execute') ) {
       print ts("Swapping tables...\n");
 
+      if ( $o->get('swap-table-name') ) {
+         $table_name = $o->get('swap-table-name');
+         $table_name =~  s/%T/$orig_tbl->{name}/g;
+         use POSIX 'strftime';
+         my $timestamp = strftime("%Y%m%d%H%M%S", localtime(time()));
+         $table_name =~  s/%D/$timestamp/g;
+      } else {
+         $table_name = $prefix . $table_name;
+      }
+
       while ( $name_tries-- ) {
          $table_name = $prefix . $table_name;
 
@@ -10359,7 +10720,10 @@
            . ' LIKE ' . $q->literal_like($orig_tbl->{tbl});
    PTDEBUG && _d($sql);
    my $triggers = $dbh->selectall_arrayref($sql);
-   if ( $triggers && @$triggers ) {
+   # Don't quit on existing triggers if running from a saved state. The triggers
+   # are expected to be present.
+   if ( $triggers && @$triggers &&
+         (!defined $loaded_step || (defined $loaded_step && !grep { $_ eq $loaded_step } qw(triggers copy rename)))) {
       die "The table $orig_tbl->{name} has triggers.  This tool "
          . "needs to create its own triggers, so the table cannot "
          . "already have triggers.\n";
@@ -10709,8 +11074,11 @@
    @drop_trigger_sqls = ();
    foreach my $trg ( @triggers ) {
       my ($name, $sql) = @$trg;
-      print $sql, "\n" if $o->get('print');
-      if ( $o->get('execute') ) {
+      print "$name trigger: $sql\n";
+      # Don't create triggers if running from a saved state. They should already
+      # be there.
+      if ( $o->get('execute') &&
+         (!defined $loaded_step || (defined $loaded_step && !grep { $_ eq $loaded_step } qw(triggers copy rename)))) {
          osc_retry(
             Cxn     => $cxn,
             Retry   => $retry,

Please let me know how to patch it without getting failed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ptosc-patch/0001-ptosc-square-changes.patch, the target file 3.0, and the generated 3.0.rej file; compare the three failed hunks with the latest pt-online-schema-change 3.0.13 source. Done means the patch applies without failed hunks and no reject file is produced.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.