@@ -408,6 +408,9 @@ bool Ndb_metadata_sync::sync_logfile_group(THD *thd,
408
408
ndb_log_info (" Failed to acquire MDL on logfile group '%s'" ,
409
409
lfg_name.c_str ());
410
410
temp_error = true ;
411
+ // Since it's a temporary error, the THD conditions should be cleared but
412
+ // not logged
413
+ clear_thd_conditions (thd);
411
414
return false ;
412
415
}
413
416
@@ -420,15 +423,16 @@ bool Ndb_metadata_sync::sync_logfile_group(THD *thd,
420
423
NdbDictionary::Dictionary *dict = thd_ndb->ndb ->getDictionary ();
421
424
bool exists_in_NDB;
422
425
if (!ndb_logfile_group_exists (dict, lfg_name, exists_in_NDB)) {
423
- ndb_log_info (" Failed to determine if logfile group '%s' exists in NDB" ,
424
- lfg_name.c_str ());
426
+ ndb_log_warning (" Failed to determine if logfile group '%s' exists in NDB" ,
427
+ lfg_name.c_str ());
425
428
return false ;
426
429
}
427
430
428
431
bool exists_in_DD;
429
432
if (!dd_client.logfile_group_exists (lfg_name.c_str (), exists_in_DD)) {
430
- ndb_log_info (" Failed to determine if logfile group '%s' exists in DD" ,
431
- lfg_name.c_str ());
433
+ log_and_clear_thd_conditions (thd, condition_logging_level::WARNING);
434
+ ndb_log_warning (" Failed to determine if logfile group '%s' exists in DD" ,
435
+ lfg_name.c_str ());
432
436
return false ;
433
437
}
434
438
@@ -441,6 +445,7 @@ bool Ndb_metadata_sync::sync_logfile_group(THD *thd,
441
445
// Logfile group exists in DD but not in NDB. Correct this by removing the
442
446
// logfile group from DD
443
447
if (!dd_client.drop_logfile_group (lfg_name.c_str ())) {
448
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
444
449
ndb_log_error (" Failed to drop logfile group '%s' in DD" ,
445
450
lfg_name.c_str ());
446
451
return false ;
@@ -462,13 +467,14 @@ bool Ndb_metadata_sync::sync_logfile_group(THD *thd,
462
467
int ndb_id, ndb_version;
463
468
if (!ndb_get_logfile_group_id_and_version (dict, lfg_name, ndb_id,
464
469
ndb_version)) {
465
- ndb_log_info (" Failed to get id and version of logfile group '%s'" ,
466
- lfg_name.c_str ());
470
+ ndb_log_error (" Failed to get id and version of logfile group '%s'" ,
471
+ lfg_name.c_str ());
467
472
return false ;
468
473
}
469
474
if (!dd_client.install_logfile_group (lfg_name.c_str (), undofile_names, ndb_id,
470
475
ndb_version,
471
476
false /* force_overwrite */ )) {
477
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
472
478
ndb_log_error (" Failed to install logfile group '%s' in DD" ,
473
479
lfg_name.c_str ());
474
480
return false ;
@@ -484,6 +490,9 @@ bool Ndb_metadata_sync::sync_tablespace(THD *thd, const std::string &ts_name,
484
490
if (!dd_client.mdl_lock_tablespace_exclusive (ts_name.c_str (), true , 10 )) {
485
491
ndb_log_info (" Failed to acquire MDL on tablespace '%s'" , ts_name.c_str ());
486
492
temp_error = true ;
493
+ // Since it's a temporary error, the THD conditions should be cleared but
494
+ // not logged
495
+ clear_thd_conditions (thd);
487
496
return false ;
488
497
}
489
498
@@ -496,15 +505,16 @@ bool Ndb_metadata_sync::sync_tablespace(THD *thd, const std::string &ts_name,
496
505
NdbDictionary::Dictionary *dict = thd_ndb->ndb ->getDictionary ();
497
506
bool exists_in_NDB;
498
507
if (!ndb_tablespace_exists (dict, ts_name, exists_in_NDB)) {
499
- ndb_log_info (" Failed to determine if tablespace '%s' exists in NDB" ,
500
- ts_name.c_str ());
508
+ ndb_log_warning (" Failed to determine if tablespace '%s' exists in NDB" ,
509
+ ts_name.c_str ());
501
510
return false ;
502
511
}
503
512
504
513
bool exists_in_DD;
505
514
if (!dd_client.tablespace_exists (ts_name.c_str (), exists_in_DD)) {
506
- ndb_log_info (" Failed to determine if tablespace '%s' exists in DD" ,
507
- ts_name.c_str ());
515
+ log_and_clear_thd_conditions (thd, condition_logging_level::WARNING);
516
+ ndb_log_warning (" Failed to determine if tablespace '%s' exists in DD" ,
517
+ ts_name.c_str ());
508
518
return false ;
509
519
}
510
520
@@ -517,6 +527,7 @@ bool Ndb_metadata_sync::sync_tablespace(THD *thd, const std::string &ts_name,
517
527
// Tablespace exists in DD but not in NDB. Correct this by removing the
518
528
// tablespace from DD
519
529
if (!dd_client.drop_tablespace (ts_name.c_str ())) {
530
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
520
531
ndb_log_error (" Failed to drop tablespace '%s' in DD" , ts_name.c_str ());
521
532
return false ;
522
533
}
@@ -542,6 +553,7 @@ bool Ndb_metadata_sync::sync_tablespace(THD *thd, const std::string &ts_name,
542
553
}
543
554
if (!dd_client.install_tablespace (ts_name.c_str (), datafile_names, ndb_id,
544
555
ndb_version, false /* force_overwrite */ )) {
556
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
545
557
ndb_log_error (" Failed to install tablespace '%s' in DD" , ts_name.c_str ());
546
558
return false ;
547
559
}
@@ -592,6 +604,9 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
592
604
ndb_log_info (" Failed to acquire MDL on table '%s.%s'" , db_name.c_str (),
593
605
table_name.c_str ());
594
606
temp_error = true ;
607
+ // Since it's a temporary error, the THD conditions should be cleared but
608
+ // not logged
609
+ clear_thd_conditions (thd);
595
610
return false ;
596
611
}
597
612
@@ -606,16 +621,17 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
606
621
NdbDictionary::Dictionary *dict = ndb->getDictionary ();
607
622
bool exists_in_NDB;
608
623
if (!ndb_table_exists (dict, db_name, table_name, exists_in_NDB)) {
609
- ndb_log_info (" Failed to determine if table '%s.%s' exists in NDB" ,
610
- db_name.c_str (), table_name.c_str ());
624
+ ndb_log_warning (" Failed to determine if table '%s.%s' exists in NDB" ,
625
+ db_name.c_str (), table_name.c_str ());
611
626
return false ;
612
627
}
613
628
614
629
bool exists_in_DD;
615
630
if (!dd_client.table_exists (db_name.c_str (), table_name.c_str (),
616
631
exists_in_DD)) {
617
- ndb_log_info (" Failed to determine if table '%s.%s' exists in DD" ,
618
- db_name.c_str (), table_name.c_str ());
632
+ log_and_clear_thd_conditions (thd, condition_logging_level::WARNING);
633
+ ndb_log_warning (" Failed to determine if table '%s.%s' exists in DD" ,
634
+ db_name.c_str (), table_name.c_str ());
619
635
return false ;
620
636
}
621
637
@@ -630,8 +646,9 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
630
646
bool local_table;
631
647
if (!dd_client.is_local_table (db_name.c_str (), table_name.c_str (),
632
648
local_table)) {
633
- ndb_log_info (" Failed to determine if table '%s.%s' was a local table" ,
634
- db_name.c_str (), table_name.c_str ());
649
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
650
+ ndb_log_error (" Failed to determine if table '%s.%s' was a local table" ,
651
+ db_name.c_str (), table_name.c_str ());
635
652
return false ;
636
653
}
637
654
if (local_table) {
@@ -643,12 +660,14 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
643
660
Ndb_referenced_tables_invalidator invalidator (thd, dd_client);
644
661
if (!dd_client.remove_table (db_name.c_str (), table_name.c_str (),
645
662
&invalidator)) {
663
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
646
664
ndb_log_error (" Failed to drop table '%s.%s' in DD" , db_name.c_str (),
647
665
table_name.c_str ());
648
666
return false ;
649
667
}
650
668
651
669
if (!invalidator.invalidate ()) {
670
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
652
671
ndb_log_error (
653
672
" Failed to invalidate tables referencing table '%s.%s' in "
654
673
" DD" ,
@@ -659,15 +678,15 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
659
678
// Drop share if it exists
660
679
drop_ndb_share (db_name.c_str (), table_name.c_str ());
661
680
ndb_tdc_close_cached_table (thd, db_name.c_str (), table_name.c_str ());
662
- dd_client.commit ();
663
- ndb_log_info (" Table '%s.%s' dropped from DD" , db_name.c_str (),
664
- table_name.c_str ());
665
681
666
682
// Invalidate the table in NdbApi
667
683
if (ndb->setDatabaseName (db_name.c_str ())) {
668
684
ndb_log_error (" Failed to set database name of NDB object" );
669
685
return false ;
670
686
}
687
+ dd_client.commit ();
688
+ ndb_log_info (" Table '%s.%s' dropped from DD" , db_name.c_str (),
689
+ table_name.c_str ());
671
690
Ndb_table_guard ndbtab_guard (dict, table_name.c_str ());
672
691
ndbtab_guard.invalidate ();
673
692
return true ;
@@ -702,6 +721,7 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
702
721
db_name.c_str (), table_name.c_str (),
703
722
static_cast <const unsigned char *>(unpacked_data), unpacked_len,
704
723
false )) {
724
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
705
725
ndb_log_error (
706
726
" Failed to migrate table '%s.%s' with extra metadata "
707
727
" version 1" ,
@@ -712,15 +732,17 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
712
732
free (unpacked_data);
713
733
const dd::Table *dd_table;
714
734
if (!dd_client.get_table (db_name.c_str (), table_name.c_str (), &dd_table)) {
735
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
715
736
ndb_log_error (
716
737
" Failed to get table '%s.%s' from DD after it was installed" ,
717
738
db_name.c_str (), table_name.c_str ());
718
739
return false ;
719
740
}
720
741
if (ndbcluster_binlog_setup_table (thd, ndb, db_name.c_str (),
721
742
table_name.c_str (), dd_table) != 0 ) {
722
- ndb_log_info (" Failed to setup binlogging for table '%s.%s'" ,
723
- db_name.c_str (), table_name.c_str ());
743
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
744
+ ndb_log_error (" Failed to setup binlogging for table '%s.%s'" ,
745
+ db_name.c_str (), table_name.c_str ());
724
746
return false ;
725
747
}
726
748
dd_client.commit ();
@@ -739,14 +761,18 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
739
761
ndb_log_info (" Failed to acquire MDL on tablespace '%s'" ,
740
762
tablespace_name.c_str ());
741
763
temp_error = true ;
764
+ // Since it's a temporary error, the THD conditions should be cleared but
765
+ // not logged
766
+ clear_thd_conditions (thd);
742
767
return false ;
743
768
}
744
769
745
770
bool tablespace_exists;
746
771
if (!dd_client.tablespace_exists (tablespace_name.c_str (),
747
772
tablespace_exists)) {
748
- ndb_log_error (" Failed to determine if tablespace '%s' exists in DD" ,
749
- tablespace_name.c_str ());
773
+ log_and_clear_thd_conditions (thd, condition_logging_level::WARNING);
774
+ ndb_log_warning (" Failed to determine if tablespace '%s' exists in DD" ,
775
+ tablespace_name.c_str ());
750
776
return false ;
751
777
}
752
778
if (!tablespace_exists) {
@@ -770,6 +796,9 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
770
796
" hasn't been synced yet" ,
771
797
db_name.c_str (), table_name.c_str (), tablespace_name.c_str ());
772
798
temp_error = true ;
799
+ // Since it's a temporary error, the THD conditions should be cleared
800
+ // but not logged
801
+ clear_thd_conditions (thd);
773
802
return false ;
774
803
}
775
804
}
@@ -779,26 +808,30 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &db_name,
779
808
tab->getObjectId (), tab->getObjectVersion (),
780
809
tab->getPartitionCount (), tablespace_name, false ,
781
810
&invalidator)) {
811
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
782
812
ndb_log_error (" Failed to install table '%s.%s' in DD" , db_name.c_str (),
783
813
table_name.c_str ());
784
814
return false ;
785
815
}
786
816
787
817
if (!invalidator.invalidate ()) {
818
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
788
819
ndb_log_error (" Failed to invalidate tables referencing table '%s.%s' in DD" ,
789
820
db_name.c_str (), table_name.c_str ());
790
821
return false ;
791
822
}
792
823
const dd::Table *dd_table;
793
824
if (!dd_client.get_table (db_name.c_str (), table_name.c_str (), &dd_table)) {
825
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
794
826
ndb_log_error (" Failed to get table '%s.%s' from DD after it was installed" ,
795
827
db_name.c_str (), table_name.c_str ());
796
828
return false ;
797
829
}
798
830
if (ndbcluster_binlog_setup_table (thd, ndb, db_name.c_str (),
799
831
table_name.c_str (), dd_table) != 0 ) {
800
- ndb_log_info (" Failed to setup binlogging for table '%s.%s'" ,
801
- db_name.c_str (), table_name.c_str ());
832
+ log_and_clear_thd_conditions (thd, condition_logging_level::ERROR);
833
+ ndb_log_error (" Failed to setup binlogging for table '%s.%s'" ,
834
+ db_name.c_str (), table_name.c_str ());
802
835
return false ;
803
836
}
804
837
dd_client.commit ();
0 commit comments