@@ -4164,10 +4164,6 @@ a file name for --log-bin-index option", opt_binlog_index_name);
4164
4164
// / @todo: this looks suspicious, revisit this /sven
4165
4165
enum_gtid_mode gtid_mode= get_gtid_mode (GTID_MODE_LOCK_NONE);
4166
4166
4167
- /* TODO: remove this. */
4168
- if (gtid_mode != GTID_MODE_OFF && opt_bootstrap)
4169
- _gtid_mode= GTID_MODE_OFF;
4170
-
4171
4167
if (gtid_mode == GTID_MODE_ON &&
4172
4168
_gtid_consistency_mode != GTID_CONSISTENCY_MODE_ON)
4173
4169
{
@@ -4603,158 +4599,157 @@ int mysqld_main(int argc, char **argv)
4603
4599
Each server should have one UUID. We will create it automatically, if it
4604
4600
does not exist.
4605
4601
*/
4606
- if (!opt_bootstrap )
4602
+ if (init_server_auto_options () )
4607
4603
{
4608
- if (init_server_auto_options ())
4609
- {
4610
- sql_print_error (" Initialization of the server's UUID failed because it could"
4611
- " not be read from the auto.cnf file. If this is a new"
4612
- " server, the initialization failed because it was not"
4613
- " possible to generate a new UUID." );
4614
- unireg_abort (MYSQLD_ABORT_EXIT);
4615
- }
4604
+ sql_print_error (" Initialization of the server's UUID failed because it could"
4605
+ " not be read from the auto.cnf file. If this is a new"
4606
+ " server, the initialization failed because it was not"
4607
+ " possible to generate a new UUID." );
4608
+ unireg_abort (MYSQLD_ABORT_EXIT);
4609
+ }
4616
4610
4617
- /*
4618
- Add server_uuid to the sid_map. This must be done after
4619
- server_uuid has been initialized in init_server_auto_options and
4620
- after the binary log (and sid_map file) has been initialized in
4621
- init_server_components().
4622
-
4623
- No error message is needed: init_sid_map() prints a message.
4624
-
4625
- Strictly speaking, this is not currently needed when
4626
- opt_bin_log==0, since the variables that gtid_state->init
4627
- initializes are not currently used in that case. But we call it
4628
- regardless to avoid possible future bugs if gtid_state ever
4629
- needs to do anything else.
4630
- */
4631
- global_sid_lock->rdlock ();
4632
- int ret= gtid_state->init ();
4633
- global_sid_lock->unlock ();
4634
- // Initialize executed_gtids from mysql.gtid_executed table.
4635
- if (gtid_state->read_gtid_executed_from_table () == -1 )
4636
- unireg_abort (1 );
4611
+ /*
4612
+ Add server_uuid to the sid_map. This must be done after
4613
+ server_uuid has been initialized in init_server_auto_options and
4614
+ after the binary log (and sid_map file) has been initialized in
4615
+ init_server_components().
4616
+
4617
+ No error message is needed: init_sid_map() prints a message.
4618
+
4619
+ Strictly speaking, this is not currently needed when
4620
+ opt_bin_log==0, since the variables that gtid_state->init
4621
+ initializes are not currently used in that case. But we call it
4622
+ regardless to avoid possible future bugs if gtid_state ever
4623
+ needs to do anything else.
4624
+ */
4625
+ global_sid_lock->rdlock ();
4626
+ int gtid_ret= gtid_state->init ();
4627
+ global_sid_lock->unlock ();
4637
4628
4638
- if (opt_bin_log)
4639
- {
4640
- if (ret)
4641
- unireg_abort (MYSQLD_ABORT_EXIT);
4629
+ if (gtid_ret)
4630
+ unireg_abort (MYSQLD_ABORT_EXIT);
4642
4631
4643
- /*
4644
- Initialize GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED from
4645
- gtid_executed table and binlog files during server startup.
4646
- */
4647
- Gtid_set *executed_gtids=
4648
- const_cast <Gtid_set *>(gtid_state->get_executed_gtids ());
4649
- Gtid_set *lost_gtids=
4650
- const_cast <Gtid_set *>(gtid_state->get_lost_gtids ());
4651
- Gtid_set *gtids_only_in_table=
4652
- const_cast <Gtid_set *>(gtid_state->get_gtids_only_in_table ());
4653
- Gtid_set *previous_gtids_logged=
4654
- const_cast <Gtid_set *>(gtid_state->get_previous_gtids_logged ());
4655
-
4656
- Gtid_set purged_gtids_from_binlog (global_sid_map, global_sid_lock);
4657
- Gtid_set gtids_in_binlog (global_sid_map, global_sid_lock);
4658
- Gtid_set gtids_in_binlog_not_in_table (global_sid_map, global_sid_lock);
4659
-
4660
- if (mysql_bin_log.init_gtid_sets (>ids_in_binlog,
4661
- &purged_gtids_from_binlog,
4662
- opt_master_verify_checksum,
4663
- true /* true=need lock*/ ,
4664
- NULL /* trx_parser*/ ,
4665
- NULL /* gtid_partial_trx*/ ,
4666
- true /* is_server_starting*/ ))
4667
- unireg_abort (MYSQLD_ABORT_EXIT);
4632
+ // Initialize executed_gtids from mysql.gtid_executed table.
4633
+ if (gtid_state->read_gtid_executed_from_table () == -1 )
4634
+ unireg_abort (1 );
4668
4635
4669
- global_sid_lock->wrlock ();
4636
+ if (opt_bin_log)
4637
+ {
4638
+ /*
4639
+ Initialize GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED from
4640
+ gtid_executed table and binlog files during server startup.
4641
+ */
4642
+ Gtid_set *executed_gtids=
4643
+ const_cast <Gtid_set *>(gtid_state->get_executed_gtids ());
4644
+ Gtid_set *lost_gtids=
4645
+ const_cast <Gtid_set *>(gtid_state->get_lost_gtids ());
4646
+ Gtid_set *gtids_only_in_table=
4647
+ const_cast <Gtid_set *>(gtid_state->get_gtids_only_in_table ());
4648
+ Gtid_set *previous_gtids_logged=
4649
+ const_cast <Gtid_set *>(gtid_state->get_previous_gtids_logged ());
4650
+
4651
+ Gtid_set purged_gtids_from_binlog (global_sid_map, global_sid_lock);
4652
+ Gtid_set gtids_in_binlog (global_sid_map, global_sid_lock);
4653
+ Gtid_set gtids_in_binlog_not_in_table (global_sid_map, global_sid_lock);
4654
+
4655
+ if (mysql_bin_log.init_gtid_sets (>ids_in_binlog,
4656
+ &purged_gtids_from_binlog,
4657
+ opt_master_verify_checksum,
4658
+ true /* true=need lock*/ ,
4659
+ NULL /* trx_parser*/ ,
4660
+ NULL /* gtid_partial_trx*/ ,
4661
+ true /* is_server_starting*/ ))
4662
+ unireg_abort (MYSQLD_ABORT_EXIT);
4670
4663
4671
- if (!gtids_in_binlog.is_empty () &&
4672
- !gtids_in_binlog.is_subset (executed_gtids))
4673
- {
4674
- gtids_in_binlog_not_in_table.add_gtid_set (>ids_in_binlog);
4675
- if (!executed_gtids->is_empty ())
4676
- gtids_in_binlog_not_in_table.remove_gtid_set (executed_gtids);
4677
- /*
4678
- Save unsaved GTIDs into gtid_executed table, in the following
4679
- four cases:
4680
- 1. the upgrade case.
4681
- 2. the case that a slave is provisioned from a backup of
4682
- the master and the slave is cleaned by RESET MASTER
4683
- and RESET SLAVE before this.
4684
- 3. the case that no binlog rotation happened from the
4685
- last RESET MASTER on the server before it crashes.
4686
- 4. The set of GTIDs of the last binlog is not saved into the
4687
- gtid_executed table if server crashes, so we save it into
4688
- gtid_executed table and executed_gtids during recovery
4689
- from the crash.
4690
- */
4691
- if (gtid_state->save (>ids_in_binlog_not_in_table) == -1 )
4692
- {
4693
- global_sid_lock->unlock ();
4694
- unireg_abort (MYSQLD_ABORT_EXIT);
4695
- }
4696
- executed_gtids->add_gtid_set (>ids_in_binlog_not_in_table);
4697
- }
4664
+ global_sid_lock->wrlock ();
4698
4665
4699
- /* gtids_only_in_table= executed_gtids - gtids_in_binlog */
4700
- if (gtids_only_in_table->add_gtid_set (executed_gtids) !=
4701
- RETURN_STATUS_OK)
4702
- {
4703
- global_sid_lock->unlock ();
4704
- unireg_abort (MYSQLD_ABORT_EXIT);
4705
- }
4706
- gtids_only_in_table->remove_gtid_set (>ids_in_binlog);
4666
+ if (!gtids_in_binlog.is_empty () &&
4667
+ !gtids_in_binlog.is_subset (executed_gtids))
4668
+ {
4669
+ gtids_in_binlog_not_in_table.add_gtid_set (>ids_in_binlog);
4670
+ if (!executed_gtids->is_empty ())
4671
+ gtids_in_binlog_not_in_table.remove_gtid_set (executed_gtids);
4707
4672
/*
4708
- lost_gtids = executed_gtids -
4709
- (gtids_in_binlog - purged_gtids_from_binlog)
4710
- = gtids_only_in_table + purged_gtids_from_binlog;
4673
+ Save unsaved GTIDs into gtid_executed table, in the following
4674
+ four cases:
4675
+ 1. the upgrade case.
4676
+ 2. the case that a slave is provisioned from a backup of
4677
+ the master and the slave is cleaned by RESET MASTER
4678
+ and RESET SLAVE before this.
4679
+ 3. the case that no binlog rotation happened from the
4680
+ last RESET MASTER on the server before it crashes.
4681
+ 4. The set of GTIDs of the last binlog is not saved into the
4682
+ gtid_executed table if server crashes, so we save it into
4683
+ gtid_executed table and executed_gtids during recovery
4684
+ from the crash.
4711
4685
*/
4712
- DBUG_ASSERT (lost_gtids->is_empty ());
4713
- if (lost_gtids->add_gtid_set (gtids_only_in_table) != RETURN_STATUS_OK ||
4714
- lost_gtids->add_gtid_set (&purged_gtids_from_binlog) !=
4715
- RETURN_STATUS_OK)
4686
+ if (gtid_state->save (>ids_in_binlog_not_in_table) == -1 )
4716
4687
{
4717
4688
global_sid_lock->unlock ();
4718
4689
unireg_abort (MYSQLD_ABORT_EXIT);
4719
4690
}
4691
+ executed_gtids->add_gtid_set (>ids_in_binlog_not_in_table);
4692
+ }
4720
4693
4721
- /* Prepare previous_gtids_logged for next binlog */
4722
- if (previous_gtids_logged->add_gtid_set (>ids_in_binlog) !=
4723
- RETURN_STATUS_OK)
4724
- {
4725
- global_sid_lock->unlock ();
4726
- unireg_abort (MYSQLD_ABORT_EXIT);
4727
- }
4694
+ /* gtids_only_in_table= executed_gtids - gtids_in_binlog */
4695
+ if (gtids_only_in_table->add_gtid_set (executed_gtids) !=
4696
+ RETURN_STATUS_OK)
4697
+ {
4698
+ global_sid_lock->unlock ();
4699
+ unireg_abort (MYSQLD_ABORT_EXIT);
4700
+ }
4701
+ gtids_only_in_table->remove_gtid_set (>ids_in_binlog);
4702
+ /*
4703
+ lost_gtids = executed_gtids -
4704
+ (gtids_in_binlog - purged_gtids_from_binlog)
4705
+ = gtids_only_in_table + purged_gtids_from_binlog;
4706
+ */
4707
+ DBUG_ASSERT (lost_gtids->is_empty ());
4708
+ if (lost_gtids->add_gtid_set (gtids_only_in_table) != RETURN_STATUS_OK ||
4709
+ lost_gtids->add_gtid_set (&purged_gtids_from_binlog) !=
4710
+ RETURN_STATUS_OK)
4711
+ {
4712
+ global_sid_lock->unlock ();
4713
+ unireg_abort (MYSQLD_ABORT_EXIT);
4714
+ }
4728
4715
4729
- /*
4730
- Write the previous set of gtids at this point because during
4731
- the creation of the binary log this is not done as we cannot
4732
- move the init_gtid_sets() to a place before openning the binary
4733
- log. This requires some investigation.
4716
+ /* Prepare previous_gtids_logged for next binlog */
4717
+ if (previous_gtids_logged->add_gtid_set (>ids_in_binlog) !=
4718
+ RETURN_STATUS_OK)
4719
+ {
4720
+ global_sid_lock->unlock ();
4721
+ unireg_abort (MYSQLD_ABORT_EXIT);
4722
+ }
4734
4723
4735
- /Alfranio
4736
- */
4737
- Previous_gtids_log_event prev_gtids_ev (>ids_in_binlog);
4724
+ /*
4725
+ Write the previous set of gtids at this point because during
4726
+ the creation of the binary log this is not done as we cannot
4727
+ move the init_gtid_sets() to a place before openning the binary
4728
+ log. This requires some investigation.
4738
4729
4739
- global_sid_lock->unlock ();
4730
+ /Alfranio
4731
+ */
4732
+ Previous_gtids_log_event prev_gtids_ev (>ids_in_binlog);
4740
4733
4741
- (prev_gtids_ev.common_footer )->checksum_alg =
4742
- static_cast <enum_binlog_checksum_alg>(binlog_checksum_options);
4734
+ global_sid_lock->unlock ();
4743
4735
4744
- if (prev_gtids_ev.write (mysql_bin_log.get_log_file ()))
4745
- unireg_abort (MYSQLD_ABORT_EXIT);
4746
- mysql_bin_log.add_bytes_written (
4747
- prev_gtids_ev.common_header ->data_written );
4736
+ (prev_gtids_ev.common_footer )->checksum_alg =
4737
+ static_cast <enum_binlog_checksum_alg>(binlog_checksum_options);
4748
4738
4749
- if (flush_io_cache (mysql_bin_log.get_log_file ()) ||
4750
- mysql_file_sync (mysql_bin_log. get_log_file ()-> file , MYF (MY_WME)))
4751
- unireg_abort (MYSQLD_ABORT_EXIT);
4752
- mysql_bin_log. update_binlog_end_pos ( );
4739
+ if (prev_gtids_ev. write (mysql_bin_log.get_log_file ()))
4740
+ unireg_abort (MYSQLD_ABORT_EXIT);
4741
+ mysql_bin_log. add_bytes_written (
4742
+ prev_gtids_ev. common_header -> data_written );
4753
4743
4754
- (void ) RUN_HOOK (server_state, after_engine_recovery, (NULL ));
4755
- }
4744
+ if (flush_io_cache (mysql_bin_log.get_log_file ()) ||
4745
+ mysql_file_sync (mysql_bin_log.get_log_file ()->file , MYF (MY_WME)))
4746
+ unireg_abort (MYSQLD_ABORT_EXIT);
4747
+ mysql_bin_log.update_binlog_end_pos ();
4748
+
4749
+ (void ) RUN_HOOK (server_state, after_engine_recovery, (NULL ));
4756
4750
}
4757
4751
4752
+
4758
4753
if (init_ssl ())
4759
4754
unireg_abort (MYSQLD_ABORT_EXIT);
4760
4755
if (network_init ())
0 commit comments