~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log.cc

  • Committer: Monty Taylor
  • Date: 2009-01-05 22:31:09 UTC
  • mfrom: (755.2.2 drizzle-work)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: mordred@inaugust.com-20090105223109-fhqvb830ftho6r6i
MergedĀ fromĀ Mark.

Show diffs side-by-side

added added

removed removed

Lines of Context:
327
327
  if (my_b_read(log, (unsigned char*) magic, sizeof(magic)))
328
328
  {
329
329
    *errmsg = _("I/O error reading the header from the binary log");
330
 
    sql_print_error("%s, errno=%d, io cache code=%d", *errmsg, my_errno,
 
330
    errmsg_printf(ERRMSG_LVL_ERROR, "%s, errno=%d, io cache code=%d", *errmsg, my_errno,
331
331
                    log->error);
332
332
    return 1;
333
333
  }
348
348
  if ((file = my_open(log_file_name, O_RDONLY,
349
349
                      MYF(MY_WME))) < 0)
350
350
  {
351
 
    sql_print_error(_("Failed to open log (file '%s', errno %d)"),
 
351
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to open log (file '%s', errno %d)"),
352
352
                    log_file_name, my_errno);
353
353
    *errmsg = _("Could not open log file");
354
354
    goto err;
356
356
  if (init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0,
357
357
                    MYF(MY_WME|MY_DONT_CHECK_FILESIZE)))
358
358
  {
359
 
    sql_print_error(_("Failed to create a cache on log (file '%s')"),
 
359
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to create a cache on log (file '%s')"),
360
360
                    log_file_name);
361
361
    *errmsg = _("Could not open log file");
362
362
    goto err;
508
508
  return(0);
509
509
 
510
510
err:
511
 
  sql_print_error(_("Could not use %s for logging (error %d). "
 
511
  errmsg_printf(ERRMSG_LVL_ERROR, _("Could not use %s for logging (error %d). "
512
512
                    "Turning logging off for the whole duration of the "
513
513
                    "Drizzle server process. "
514
514
                    "To turn it on again: fix the cause, "
569
569
    if (my_sync(log_file.file, MYF(MY_WME)) && ! write_error)
570
570
    {
571
571
      write_error= 1;
572
 
      sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
 
572
      errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_ERROR_ON_WRITE), name, errno);
573
573
    }
574
574
 
575
575
    if (my_close(log_file.file, MYF(MY_WME)) && ! write_error)
576
576
    {
577
577
      write_error= 1;
578
 
      sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
 
578
      errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_ERROR_ON_WRITE), name, errno);
579
579
    }
580
580
  }
581
581
 
611
611
    {
612
612
      if (find_uniq_filename(new_name))
613
613
      {
614
 
        sql_print_error(ER(ER_NO_UNIQUE_LOGFILE), log_name);
 
614
        errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_NO_UNIQUE_LOGFILE), log_name);
615
615
        return 1;
616
616
      }
617
617
    }
873
873
  return(0);
874
874
 
875
875
err:
876
 
  sql_print_error(_("Could not use %s for logging (error %d). "
 
876
  errmsg_printf(ERRMSG_LVL_ERROR, _("Could not use %s for logging (error %d). "
877
877
                    "Turning logging off for the whole duration of the "
878
878
                    "Drizzle server process. "
879
879
                    "To turn it on again: fix the cause, "
1141
1141
        push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1142
1142
                            ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1143
1143
                            linfo.log_file_name);
1144
 
        sql_print_information(_("Failed to delete file '%s'"),
 
1144
        errmsg_printf(ERRMSG_LVL_INFO, _("Failed to delete file '%s'"),
1145
1145
                              linfo.log_file_name);
1146
1146
        my_errno= 0;
1147
1147
        error= 0;
1172
1172
      push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1173
1173
                          ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1174
1174
                          index_file_name);
1175
 
      sql_print_information(_("Failed to delete file '%s'"),
 
1175
      errmsg_printf(ERRMSG_LVL_INFO, _("Failed to delete file '%s'"),
1176
1176
                            index_file_name);
1177
1177
      my_errno= 0;
1178
1178
      error= 0;
1277
1277
        (error=find_next_log(&rli->linfo, 0)))))
1278
1278
  {
1279
1279
    char buff[22];
1280
 
    sql_print_error(_("next log error: %d  offset: %s  log: %s included: %d"),
 
1280
    errmsg_printf(ERRMSG_LVL_ERROR, _("next log error: %d  offset: %s  log: %s included: %d"),
1281
1281
                    error,
1282
1282
                    llstr(rli->linfo.index_file_offset,buff),
1283
1283
                    rli->group_relay_log_name.c_str(),
1387
1387
        push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1388
1388
                            ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1389
1389
                            log_info.log_file_name);
1390
 
        sql_print_information(_("Failed to execute stat() on file '%s'"),
 
1390
        errmsg_printf(ERRMSG_LVL_INFO, _("Failed to execute stat() on file '%s'"),
1391
1391
                              log_info.log_file_name);
1392
1392
        my_errno= 0;
1393
1393
      }
1421
1421
          push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1422
1422
                              ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1423
1423
                              log_info.log_file_name);
1424
 
          sql_print_information(_("Failed to delete file '%s'"),
 
1424
          errmsg_printf(ERRMSG_LVL_INFO, _("Failed to delete file '%s'"),
1425
1425
                                log_info.log_file_name);
1426
1426
          my_errno= 0;
1427
1427
        }
1511
1511
        push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1512
1512
                            ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1513
1513
                            log_info.log_file_name);
1514
 
        sql_print_information(_("Failed to execute stat() on file '%s'"),
 
1514
        errmsg_printf(ERRMSG_LVL_INFO, _("Failed to execute stat() on file '%s'"),
1515
1515
                              log_info.log_file_name);
1516
1516
        my_errno= 0;
1517
1517
      }
1543
1543
          push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1544
1544
                              ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1545
1545
                              log_info.log_file_name);
1546
 
          sql_print_information(_("Failed to delete file '%s'"),
 
1546
          errmsg_printf(ERRMSG_LVL_INFO, _("Failed to delete file '%s'"),
1547
1547
                                log_info.log_file_name);
1548
1548
          my_errno= 0;
1549
1549
        }
2165
2165
        goto err;
2166
2166
      if (cache->error)                         // Error on read
2167
2167
      {
2168
 
        sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno);
 
2168
        errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_ERROR_ON_READ), cache->file_name, errno);
2169
2169
        write_error=1;                          // Don't give more errors
2170
2170
        goto err;
2171
2171
      }
2197
2197
  if (!write_error)
2198
2198
  {
2199
2199
    write_error= 1;
2200
 
    sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
 
2200
    errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_ERROR_ON_WRITE), name, errno);
2201
2201
  }
2202
2202
  pthread_mutex_unlock(&LOCK_log);
2203
2203
  return(1);
2309
2309
    if (my_close(index_file.file, MYF(0)) < 0 && ! write_error)
2310
2310
    {
2311
2311
      write_error= 1;
2312
 
      sql_print_error(ER(ER_ERROR_ON_WRITE), index_file_name, errno);
 
2312
      errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_ERROR_ON_WRITE), index_file_name, errno);
2313
2313
    }
2314
2314
  }
2315
2315
  log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED;
2474
2474
  {
2475
2475
    inited= 1;
2476
2476
    crashed= true;
2477
 
    sql_print_information(_("Recovering after a crash using %s"), opt_name);
 
2477
    errmsg_printf(ERRMSG_LVL_INFO, _("Recovering after a crash using %s"), opt_name);
2478
2478
    if (tc_heuristic_recover)
2479
2479
    {
2480
 
      sql_print_error(_("Cannot perform automatic crash recovery when "
 
2480
      errmsg_printf(ERRMSG_LVL_ERROR, _("Cannot perform automatic crash recovery when "
2481
2481
                      "--tc-heuristic-recover is used"));
2482
2482
      goto err;
2483
2483
    }
2819
2819
 
2820
2820
  if (memcmp(data, tc_log_magic, sizeof(tc_log_magic)))
2821
2821
  {
2822
 
    sql_print_error(_("Bad magic header in tc log"));
 
2822
    errmsg_printf(ERRMSG_LVL_ERROR, _("Bad magic header in tc log"));
2823
2823
    goto err1;
2824
2824
  }
2825
2825
 
2829
2829
  */
2830
2830
  if (data[sizeof(tc_log_magic)] != total_ha_2pc)
2831
2831
  {
2832
 
    sql_print_error(_("Recovery failed! You must enable "
 
2832
    errmsg_printf(ERRMSG_LVL_ERROR, _("Recovery failed! You must enable "
2833
2833
                    "exactly %d storage engines that support "
2834
2834
                    "two-phase commit protocol"),
2835
2835
                    data[sizeof(tc_log_magic)]);
2857
2857
err2:
2858
2858
  hash_free(&xids);
2859
2859
err1:
2860
 
  sql_print_error(_("Crash recovery failed. Either correct the problem "
 
2860
  errmsg_printf(ERRMSG_LVL_ERROR, _("Crash recovery failed. Either correct the problem "
2861
2861
                  "(if it's, for example, out of memory error) and restart, "
2862
2862
                  "or delete tc log and start drizzled with "
2863
2863
                  "--tc-heuristic-recover={commit|rollback}"));
2887
2887
  if (!tc_heuristic_recover)
2888
2888
    return 0;
2889
2889
 
2890
 
  sql_print_information(_("Heuristic crash recovery mode"));
 
2890
  errmsg_printf(ERRMSG_LVL_INFO, _("Heuristic crash recovery mode"));
2891
2891
  if (ha_recover(0))
2892
 
    sql_print_error(_("Heuristic crash recovery failed"));
2893
 
  sql_print_information(_("Please restart mysqld without --tc-heuristic-recover"));
 
2892
    errmsg_printf(ERRMSG_LVL_ERROR, _("Heuristic crash recovery failed"));
 
2893
  errmsg_printf(ERRMSG_LVL_INFO, _("Please restart mysqld without --tc-heuristic-recover"));
2894
2894
  return 1;
2895
2895
}
2896
2896
 
2934
2934
  if ((error= find_log_pos(&log_info, NULL, 1)))
2935
2935
  {
2936
2936
    if (error != LOG_INFO_EOF)
2937
 
      sql_print_error(_("find_log_pos() failed (error: %d)"), error);
 
2937
      errmsg_printf(ERRMSG_LVL_ERROR, _("find_log_pos() failed (error: %d)"), error);
2938
2938
    else
2939
2939
      error= 0;
2940
2940
    goto err;
2958
2958
 
2959
2959
    if (error !=  LOG_INFO_EOF)
2960
2960
    {
2961
 
      sql_print_error(_("find_log_pos() failed (error: %d)"), error);
 
2961
      errmsg_printf(ERRMSG_LVL_ERROR, _("find_log_pos() failed (error: %d)"), error);
2962
2962
      goto err;
2963
2963
    }
2964
2964
 
2965
2965
    if ((file= open_binlog(&log, log_name, &errmsg)) < 0)
2966
2966
    {
2967
 
      sql_print_error("%s", errmsg);
 
2967
      errmsg_printf(ERRMSG_LVL_ERROR, "%s", errmsg);
2968
2968
      goto err;
2969
2969
    }
2970
2970
 
2972
2972
        ev->get_type_code() == FORMAT_DESCRIPTION_EVENT &&
2973
2973
        ev->flags & LOG_EVENT_BINLOG_IN_USE_F)
2974
2974
    {
2975
 
      sql_print_information(_("Recovering after a crash using %s"), opt_name);
 
2975
      errmsg_printf(ERRMSG_LVL_INFO, _("Recovering after a crash using %s"), opt_name);
2976
2976
      error= recover(&log, (Format_description_log_event *)ev);
2977
2977
    }
2978
2978
    else
3072
3072
  free_root(&mem_root, MYF(0));
3073
3073
  hash_free(&xids);
3074
3074
err1:
3075
 
  sql_print_error(_("Crash recovery failed. Either correct the problem "
 
3075
  errmsg_printf(ERRMSG_LVL_ERROR, 
 
3076
                _("Crash recovery failed. Either correct the problem "
3076
3077
                  "(if it's, for example, out of memory error) and restart, "
3077
3078
                  "or delete (or rename) binary log and start mysqld with "
3078
3079
                  "--tc-heuristic-recover={commit|rollback}"));