in mysqloperator/sidecar_main.py [0:0]
def initialize(session: 'ClassicSession', datadir: str, pod: MySQLPod, cluster: InnoDBCluster, logger: Logger) -> None:
session.run_sql("SET sql_log_bin=0")
create_root_account(session, pod, cluster, logger)
create_admin_account(session, cluster, logger)
session.run_sql("SET sql_log_bin=1")
user, password = cluster.get_admin_account()
session = connect(user, password, logger)
configure_for_innodb_cluster(mysqlsh.globals.dba, logger)
if pod.index == 0 and cluster.get_create_time() is None:
# if this is the 1st pod of the cluster, then initialize it and create default accounts
session = populate_db(datadir, session, cluster, pod, logger)
# TODO: This will fail after restarting server due to cloning - wonder why
# I only noticed this with clusterSet not with plain clone
#
# mysqlsh.DBError: MySQL Error (2013): ClassicSession.run_sql: Lost connection to MySQL server during query
session.run_sql("SET sql_log_bin=0")
old_read_only = session.run_sql("SELECT @@super_read_only").fetch_one()[0]
session.run_sql("SET GLOBAL super_read_only=0")
try:
# These need to be created on every pod and not replicated. Thus under sql_log_bin=0
# Not created earlier, as if there is initdb, for example from dump of clone, the
# creation will be overwritten and we will need to create them again in the populate method
create_metrics_account(session, cluster, logger)
create_backup_account(session, cluster, logger)
# Some commands like INSTALL [PLUGIN|COMPONENT] are not being
# replicated we run them on any restart, those have to be idempotent
# With enterprise edition activate enterprise plugins
if cluster.parsed_spec.edition == Edition.enterprise:
install_enterprise_plugins(cluster.parsed_spec.version, session, logger)
# If a Keyring setup is requested install keyring UDFs
if "keyring" in cluster.spec:
print(f"KEYRING: {cluster.spec['keyring']}")
install_keyring_udf(cluster.parsed_spec.version, session, logger)
finally:
session.run_sql("SET GLOBAL super_read_only=?", [old_read_only])
session.run_sql("SET sql_log_bin=1")