~ubuntu-branches/ubuntu/raring/mysql-5.5/raring-proposed

« back to all changes in this revision

Viewing changes to sql/log_event.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7761
7761
 
7762
7762
    // row processing loop
7763
7763
 
 
7764
    /* 
 
7765
      set the initial time of this ROWS statement if it was not done
 
7766
      before in some other ROWS event. 
 
7767
     */
 
7768
    const_cast<Relay_log_info*>(rli)->set_row_stmt_start_timestamp();
 
7769
 
7764
7770
    while (error == 0 && m_curr_row < m_rows_end)
7765
7771
    {
7766
7772
      /* in_use can have been set to NULL in close_tables_for_reopen */
9252
9258
  return result;
9253
9259
}
9254
9260
 
 
9261
/* 
 
9262
  Check if we are already spending too much time on this statement.
 
9263
  if we are, warn user that it might be because table does not have
 
9264
  a PK, but only if the warning was not printed before for this STMT.
 
9265
 
 
9266
  @param type          The event type code.
 
9267
  @param table_name    The name of the table that the slave is 
 
9268
                       operating.
 
9269
  @param is_index_scan States whether the slave is doing an index scan 
 
9270
                       or not.
 
9271
  @param rli           The relay metadata info.
 
9272
*/
 
9273
static inline 
 
9274
void issue_long_find_row_warning(Log_event_type type, 
 
9275
                                 const char *table_name,
 
9276
                                 bool is_index_scan,
 
9277
                                 const Relay_log_info *rli)
 
9278
{
 
9279
  if ((global_system_variables.log_warnings > 1 && 
 
9280
      !const_cast<Relay_log_info*>(rli)->is_long_find_row_note_printed()))
 
9281
  {
 
9282
    time_t now= my_time(0);
 
9283
    time_t stmt_ts= const_cast<Relay_log_info*>(rli)->get_row_stmt_start_timestamp();
 
9284
    
 
9285
    DBUG_EXECUTE_IF("inject_long_find_row_note", 
 
9286
                    stmt_ts-=(LONG_FIND_ROW_THRESHOLD*2););
 
9287
 
 
9288
    long delta= (long) (now - stmt_ts);
 
9289
 
 
9290
    if (delta > LONG_FIND_ROW_THRESHOLD)
 
9291
    {
 
9292
      const_cast<Relay_log_info*>(rli)->set_long_find_row_note_printed();
 
9293
      const char* evt_type= type == DELETE_ROWS_EVENT ? " DELETE" : "n UPDATE";
 
9294
      const char* scan_type= is_index_scan ? "scanning an index" : "scanning the table";
 
9295
 
 
9296
      sql_print_information("The slave is applying a ROW event on behalf of a%s statement "
 
9297
                            "on table %s and is currently taking a considerable amount "
 
9298
                            "of time (%ld seconds). This is due to the fact that it is %s "
 
9299
                            "while looking up records to be processed. Consider adding a "
 
9300
                            "primary key (or unique key) to the table to improve "
 
9301
                            "performance.", evt_type, table_name, delta, scan_type);
 
9302
    }
 
9303
  }
 
9304
}
 
9305
 
9255
9306
/**
9256
9307
  Locate the current row in event's table.
9257
9308
 
9287
9338
 
9288
9339
  TABLE *table= m_table;
9289
9340
  int error= 0;
 
9341
  bool is_table_scan= false, is_index_scan= false;
9290
9342
 
9291
9343
  /*
9292
9344
    rpl_row_tabledefs.test specifies that
9452
9504
      }
9453
9505
    }
9454
9506
 
 
9507
    is_index_scan=true;
 
9508
 
9455
9509
    /*
9456
9510
      In case key is not unique, we still have to iterate over records found
9457
9511
      and find the one which is identical to the row given. A copy of the 
9508
9562
      goto err;
9509
9563
    }
9510
9564
 
 
9565
    is_table_scan= true;
 
9566
 
9511
9567
    /* Continue until we find the right record or have made a full loop */
9512
9568
    do
9513
9569
    {
9561
9617
    goto err;
9562
9618
  }
9563
9619
ok:
 
9620
  if (is_table_scan || is_index_scan)
 
9621
    issue_long_find_row_warning(get_type_code(), m_table->alias, 
 
9622
                                is_index_scan, rli);
 
9623
 
9564
9624
  table->default_column_bitmaps();
9565
9625
  DBUG_RETURN(0);
9566
9626
 
9567
9627
err:
 
9628
  if (is_table_scan || is_index_scan)
 
9629
    issue_long_find_row_warning(get_type_code(), m_table->alias, 
 
9630
                                is_index_scan, rli);
 
9631
 
9568
9632
  table->default_column_bitmaps();
9569
9633
  DBUG_RETURN(error);
9570
9634
}