From a9eb9fafbcf20605fd70f7d2af5fb8b5f285f92a Mon Sep 17 00:00:00 2001 From: busu Date: Thu, 18 Jul 2024 11:36:39 +0800 Subject: [PATCH 1/2] release v1.6.2 --- build/conf/my.cnf | 410 ------------------ build/images/polardbx-clinic/Dockerfile | 3 +- build/images/polardbx-clinic/install_tool.sh | 5 + build/images/polardbx-exporter/Dockerfile | 6 +- build/images/polardbx-hpfs/Dockerfile | 7 +- build/images/polardbx-init/Dockerfile | 6 +- build/images/polardbx-job/Dockerfile | 5 +- build/images/polardbx-logstash/Dockerfile | 6 +- build/images/polardbx-operator/Dockerfile | 6 +- build/images/probe-proxy/Dockerfile | 6 +- build/images/xstore-tools/Dockerfile | 12 +- build/root/Makefile | 11 + charts/polardbx-logcollector/Chart.yaml | 4 +- charts/polardbx-logcollector/values.yaml | 4 +- charts/polardbx-monitor/Chart.yaml | 4 +- charts/polardbx-monitor/values.yaml | 20 +- charts/polardbx-operator/Chart.yaml | 4 +- .../controller-config-configmap.yaml | 4 +- .../host-path-file-service-daemonset.yaml | 2 +- charts/polardbx-operator/values.yaml | 7 +- cmd/polardbx-hpfs/main.go | 21 +- hack/copy_image.sh | 4 +- hack/make-rules/build-images.py | 11 +- pkg/binlogtool/cmd/truncate.go | 38 +- pkg/hpfs/backupbinlog/start.go | 6 +- pkg/hpfs/backupbinlog/watcher.go | 6 +- pkg/hpfs/cpusetbind/manager.go | 7 + pkg/hpfs/cpusetbind/system/cpuinfo.go | 2 +- pkg/hpfs/cpusetbind/system/proc.go | 8 +- pkg/hpfs/filestream/flowcontrol.go | 4 +- pkg/meta/core/gms/manager.go | 14 + pkg/meta/core/gms/manager_impl.go | 10 +- .../controllers/polardbxcluster_controller.go | 1 + .../v1/polardbx/steps/instance/object.go | 38 ++ pkg/operator/v1/xstore/meta/annotations.go | 1 + pkg/operator/v1/xstore/steps/follower/job.go | 2 +- pkg/operator/v1/xstore/steps/follower/pod.go | 10 +- .../v1/xstore/steps/instance/engine_config.go | 1 + .../v1/xstore/steps/instance/recreate.go | 4 + 39 files changed, 232 insertions(+), 488 deletions(-) delete mode 100644 build/conf/my.cnf diff --git a/build/conf/my.cnf b/build/conf/my.cnf deleted file mode 100644 index 6f7fbf7..0000000 --- a/build/conf/my.cnf +++ /dev/null @@ -1,410 +0,0 @@ -[mysqld] -auto_increment_increment = 1 -auto_increment_offset = 1 -autocommit = ON -automatic_sp_privileges = ON -avoid_temporal_upgrade = OFF -back_log = 3000 -basedir = /opt/galaxy_engine -binlog_cache_size = 1048576 -binlog_checksum = CRC32 -binlog_format = ROW -binlog_row_image = full -binlog_rows_query_log_events = ON -binlog_stmt_cache_size = 32768 -binlog_transaction_dependency_tracking = WRITESET -block_encryption_mode = "aes-128-ecb" -bulk_insert_buffer_size = 4194304 -character_set_server = utf8 -concurrent_insert = 2 -connect_timeout = 10 -core_file -datadir = /data/mysql/data -default_authentication_plugin = mysql_native_password -default_storage_engine = InnoDB -default_time_zone = +8:00 -default_week_format = 0 -delay_key_write = ON -delayed_insert_limit = 100 -delayed_insert_timeout = 300 -delayed_queue_size = 1000 -disconnect_on_expired_password = ON -div_precision_increment = 4 -end_markers_in_json = OFF -eq_range_index_dive_limit = 200 -event_scheduler = OFF -expire_logs_days = 0 -explicit_defaults_for_timestamp = OFF -flush_time = 0 -ft_max_word_len = 84 -ft_min_word_len = 4 -ft_query_expansion_limit = 20 -general_log = OFF -general_log_file = /data/mysql/log/general.log -group_concat_max_len = 1024 -host_cache_size = 644 -init_connect = '' -innodb_adaptive_flushing = ON -innodb_adaptive_flushing_lwm = 10 -innodb_adaptive_hash_index = OFF -innodb_adaptive_max_sleep_delay = 150000 -innodb_autoextend_increment = 64 -innodb_autoinc_lock_mode = 2 -innodb_buffer_pool_chunk_size = 33554432 -innodb_buffer_pool_dump_at_shutdown = ON -innodb_buffer_pool_dump_pct = 25 -innodb_buffer_pool_instances = 8 -innodb_buffer_pool_load_at_startup = ON -innodb_buffer_pool_size = 2576980377 -innodb_change_buffer_max_size = 25 -innodb_change_buffering = all -innodb_checksum_algorithm = crc32 -innodb_cmp_per_index_enabled = OFF -innodb_commit_concurrency = 0 -innodb_compression_failure_threshold_pct = 5 -innodb_compression_level = 6 -innodb_compression_pad_pct_max = 50 -innodb_concurrency_tickets = 5000 -innodb_data_file_path = ibdata1:12M:autoextend -innodb_data_file_purge = ON -innodb_data_file_purge_interval = 100 -innodb_data_file_purge_max_size = 128 -innodb_data_home_dir = /data/mysql/data -innodb_deadlock_detect = ON -innodb_disable_sort_file_cache = ON -innodb_doublewrite = 1 -innodb_fast_shutdown = 1 -innodb_file_per_table = 1 -innodb_flush_log_at_trx_commit = 1 -innodb_flush_method = O_DIRECT -innodb_flush_neighbors = 0 -innodb_flush_sync = ON -innodb_ft_cache_size = 8000000 -innodb_ft_enable_diag_print = OFF -innodb_ft_enable_stopword = ON -innodb_ft_max_token_size = 84 -innodb_ft_min_token_size = 3 -innodb_ft_num_word_optimize = 2000 -innodb_ft_result_cache_limit = 2000000000 -innodb_ft_sort_pll_degree = 2 -innodb_ft_total_cache_size = 640000000 -innodb_io_capacity = 20000 -innodb_io_capacity_max = 40000 -innodb_lock_wait_timeout = 50 -innodb_log_buffer_size = 209715200 -innodb_log_checksums = ON -innodb_log_file_size = 2147483648 -innodb_log_files_in_group = 2 -innodb_log_group_home_dir = /data/mysql/log -innodb_lru_scan_depth = 8192 -innodb_max_dirty_pages_pct = 75 -innodb_max_dirty_pages_pct_lwm = 0 -innodb_max_purge_lag = 0 -innodb_max_purge_lag_delay = 0 -innodb_max_undo_log_size = 1073741824 -innodb_monitor_disable = -innodb_monitor_enable = -innodb_old_blocks_pct = 37 -innodb_old_blocks_time = 1000 -innodb_online_alter_log_max_size = 134217728 -innodb_open_files = 20000 -innodb_optimize_fulltext_only = OFF -innodb_page_cleaners = 4 -innodb_print_all_deadlocks = ON -innodb_purge_batch_size = 300 -innodb_purge_rseg_truncate_frequency = 128 -innodb_purge_threads = 4 -innodb_random_read_ahead = OFF -innodb_read_ahead_threshold = 0 -innodb_read_io_threads = 4 -innodb_rollback_on_timeout = OFF -innodb_rollback_segments = 128 -innodb_sort_buffer_size = 1048576 -innodb_spin_wait_delay = 6 -innodb_stats_auto_recalc = ON -innodb_stats_method = nulls_equal -innodb_stats_on_metadata = OFF -innodb_stats_persistent = ON -innodb_stats_persistent_sample_pages = 20 -innodb_stats_transient_sample_pages = 8 -innodb_status_output = OFF -innodb_status_output_locks = OFF -innodb_strict_mode = ON -innodb_sync_array_size = 16 -innodb_sync_spin_loops = 30 -innodb_table_locks = ON -innodb_thread_concurrency = 0 -innodb_thread_sleep_delay = 0 -innodb_undo_directory = /data/mysql/log -innodb_use_native_aio = OFF -innodb_write_io_threads = 4 -interactive_timeout = 7200 -key_buffer_size = 16777216 -key_cache_age_threshold = 300 -key_cache_block_size = 1024 -key_cache_division_limit = 100 -lc_time_names = en_US -local_infile = ON -lock_wait_timeout = 1800 -log_bin = /data/mysql/log/mysql_bin -log_bin_trust_function_creators = ON -log_bin_use_v1_row_events = 0 -log_error = /data/mysql/log/alert.log -log_error_verbosity = 2 -log_output = "TABLE" -log_queries_not_using_indexes = OFF -log_slave_updates = 0 -log_slow_admin_statements = ON -log_slow_slave_statements = ON -log_throttle_queries_not_using_indexes = 0 -log_timestamps = SYSTEM -long_query_time = 1 -loose_async_commit_thread_count = 128 -loose_binlog_order_commits = OFF -loose_binlog_rows_query_key_content = ON -loose_boost_pk_access = 1 -loose_ccl_max_waiting_count = 0 -loose_ccl_queue_bucket_count = 4 -loose_ccl_queue_bucket_size = 64 -loose_ccl_wait_timeout = 86400 -loose_cluster_log_type_node = OFF -loose_cluster_mts_recover_use_index = ON -loose_commit_lock_done_count = 1 -loose_consensus_auto_leader_transfer = ON -loose_consensus_auto_reset_match_index = ON -loose_consensus_election_timeout = 10000 -loose_consensus_io_thread_cnt = 8 -loose_consensus_large_trx = ON -loose_consensus_log_cache_size = 536870912 -loose_consensus_max_delay_index = 10000 -loose_consensus_max_log_size = 20971520 -loose_consensus_max_packet_size = 131072 -loose_consensus_prefetch_cache_size = 268435456 -loose_consensus_prefetch_window_size = 10 -loose_consensus_worker_thread_cnt = 8 -loose_consensuslog_revise = ON -loose_daemon_memcached_option = "-t 32 -c 8000 -p15506" -loose_daemon_memcached_values_delimiter = ':;:' -loose_enable_gts = 1 -loose_enforce_gtid_consistency = ON -loose_galaxy_max_connections = 8000 -loose_galaxyx_port = 31306 -loose_gtid_mode = ON -loose_implicit_primary_key = 1 -loose_indexstat = 1 -loose_information_schema_stats_expiry = 86400 -loose_innodb_buffer_pool_in_core_file = OFF -loose_innodb_commit_cleanout_max_rows = 3 -loose_innodb_doublewrite_pages = 64 -loose_innodb_equal_gcn_visible = 0 -loose_innodb_lizard_stat_enabled = OFF -loose_innodb_log_compressed_pages = ON -loose_innodb_log_optimize_ddl = OFF -loose_innodb_log_write_ahead_size = 4096 -loose_innodb_multi_blocks_enabled = ON -loose_innodb_numa_interleave = ON -loose_innodb_parallel_read_threads = 1 -loose_innodb_prepare_wait_timeout = 5000 -loose_innodb_purge_history = 600000 -loose_innodb_scn_history_interval = 3 -loose_innodb_scn_history_keep_days = 7 -loose_innodb_scn_history_task_enabled = ON -loose_innodb_snapshot_update_gcn = 1 -loose_innodb_tcn_cache_level = block -loose_innodb_undo_retention = 1800 -loose_innodb_undo_space_reserved_size = 1024 -loose_innodb_undo_space_supremum_size = 102400 -loose_internal_tmp_mem_storage_engine = TempTable -loose_io_state = 1 -loose_log_slow_verbosity = full -loose_log_sql_fifo = /data/mysql/run/mysql.fifo -loose_log_sql_info = 1 -loose_log_sql_info_index = 1 -loose_mysqlx_max_connections = 8000 -loose_new_rpc = off -loose_optimizer_switch = index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on -loose_optimizer_trace = enabled=off,one_line=off -loose_optimizer_trace_features = greedy_search=on,range_optimizer=on,dynamic_range=on,repeated_subselect=on -loose_performance-schema_instrument = 'wait/lock/metadata/sql/mdl=ON' -loose_performance_point_lock_rwlock_enabled = ON -loose_performance_schema-instrument = 'memory/%%=COUNTED' -loose_performance_schema_accounts_size = 10000 -loose_performance_schema_consumer_events_stages_current = ON -loose_performance_schema_consumer_events_stages_history = ON -loose_performance_schema_consumer_events_stages_history_long = ON -loose_performance_schema_consumer_events_statements_current = OFF -loose_performance_schema_consumer_events_statements_history = OFF -loose_performance_schema_consumer_events_statements_history_long = OFF -loose_performance_schema_consumer_events_transactions_current = OFF -loose_performance_schema_consumer_events_transactions_history = OFF -loose_performance_schema_consumer_events_transactions_history_long = OFF -loose_performance_schema_consumer_events_waits_current = OFF -loose_performance_schema_consumer_events_waits_history = OFF -loose_performance_schema_consumer_events_waits_history_long = OFF -loose_performance_schema_consumer_global_instrumentation = OFF -loose_performance_schema_consumer_statements_digest = OFF -loose_performance_schema_consumer_thread_instrumentation = OFF -loose_performance_schema_digests_size = 10000 -loose_performance_schema_error_size = 0 -loose_performance_schema_events_stages_history_long_size = 0 -loose_performance_schema_events_stages_history_size = 0 -loose_performance_schema_events_statements_history_long_size = 0 -loose_performance_schema_events_statements_history_size = 0 -loose_performance_schema_events_transactions_history_long_size = 0 -loose_performance_schema_events_transactions_history_size = 0 -loose_performance_schema_events_waits_history_long_size = 0 -loose_performance_schema_events_waits_history_size = 0 -loose_performance_schema_hosts_size = 10000 -loose_performance_schema_instrument = '%%=OFF' -loose_performance_schema_max_cond_classes = 0 -loose_performance_schema_max_cond_instances = 10000 -loose_performance_schema_max_digest_length = 0 -loose_performance_schema_max_digest_sample_age = 0 -loose_performance_schema_max_file_classes = 0 -loose_performance_schema_max_file_handles = 0 -loose_performance_schema_max_file_instances = 1000 -loose_performance_schema_max_index_stat = 10000 -loose_performance_schema_max_memory_classes = 0 -loose_performance_schema_max_metadata_locks = 10000 -loose_performance_schema_max_mutex_classes = 0 -loose_performance_schema_max_mutex_instances = 10000 -loose_performance_schema_max_prepared_statements_instances = 1000 -loose_performance_schema_max_program_instances = 10000 -loose_performance_schema_max_rwlock_classes = 0 -loose_performance_schema_max_rwlock_instances = 10000 -loose_performance_schema_max_socket_classes = 0 -loose_performance_schema_max_socket_instances = 1000 -loose_performance_schema_max_sql_text_length = 0 -loose_performance_schema_max_stage_classes = 0 -loose_performance_schema_max_statement_classes = 0 -loose_performance_schema_max_statement_stack = 1 -loose_performance_schema_max_table_handles = 10000 -loose_performance_schema_max_table_instances = 1000 -loose_performance_schema_max_table_lock_stat = 10000 -loose_performance_schema_max_thread_classes = 0 -loose_performance_schema_max_thread_instances = 10000 -loose_performance_schema_session_connect_attrs_size = 0 -loose_performance_schema_setup_actors_size = 10000 -loose_performance_schema_setup_objects_size = 10000 -loose_performance_schema_users_size = 10000 -loose_persist_binlog_to_redo = OFF -loose_persist_binlog_to_redo_size_limit = 1048576 -loose_rds_audit_log_buffer_size = 16777216 -loose_rds_audit_log_enabled = OFF -loose_rds_audit_log_event_buffer_size = 8192 -loose_rds_audit_log_row_limit = 100000 -loose_rds_audit_log_version = MYSQL_V1 -loose_rds_check_core_file_enabled = ON -loose_recovery_apply_binlog = ON -loose_replica_read_timeout = 3000 -loose_replicate_same_server_id = OFF -loose_rotate_log_table_last_name = -loose_rpc_port = 31306 -loose_session_track_system_variables = "*" -loose_session_track_transaction_info = OFF -loose_slave_pr_mode = TABLE -loose_tablestat = 1 -loose_temptable_max_ram = 1073741824 -loose_use_myfs = 0 -low_priority_updates = 0 -lower_case_table_names = 1 -master_info_file = /data/mysql/data/master.info -master_info_repository = TABLE -master_verify_checksum = OFF -max_allowed_packet = 1073741824 -max_binlog_cache_size = 18446744073709551615 -max_binlog_size = 500M -max_binlog_stmt_cache_size = 18446744073709551615 -max_connect_errors = 65536 -max_connections = 8532 -max_error_count = 1024 -max_execution_time = 0 -max_heap_table_size = 67108864 -max_join_size = 18446744073709551615 -max_length_for_sort_data = 4096 -max_points_in_geometry = 65536 -max_prepared_stmt_count = 16382 -max_relay_log_size = 0 -max_seeks_for_key = 18446744073709551615 -max_sort_length = 1024 -max_sp_recursion_depth = 0 -max_user_connections = 8000 -max_write_lock_count = 102400 -min_examined_row_limit = 0 -myisam_sort_buffer_size = 262144 -mysql_native_password_proxy_users = OFF -net_buffer_length = 16384 -net_read_timeout = 30 -net_retry_count = 10 -net_write_timeout = 60 -ngram_token_size = 2 -open_files_limit = 615350 -opt_indexstat = ON -opt_tablestat = ON -optimizer_prune_level = 1 -optimizer_search_depth = 62 -optimizer_trace_limit = 1 -optimizer_trace_max_mem_size = 1048576 -optimizer_trace_offset = -1 -performance_schema = ON -port = 3306 -preload_buffer_size = 32768 -query_alloc_block_size = 8192 -query_prealloc_size = 8192 -range_alloc_block_size = 4096 -range_optimizer_max_mem_size = 8388608 -read_rnd_buffer_size = 442368 -relay_log = /data/mysql/log/relay.log -relay_log_index = /data/mysql/log/mysqld_relay_bin.index -relay_log_info_file = /data/mysql/log/relay_log.info -relay_log_info_repository = TABLE -relay_log_purge = OFF -relay_log_recovery = OFF -rpl_stop_slave_timeout = 300 -safe_user_create -server_id = 1747800024 -session_track_gtids = OFF -session_track_schema = ON -session_track_state_change = OFF -sha256_password_proxy_users = OFF -show_old_temporals = OFF -skip_external_locking -skip_slave_start = OFF -skip_ssl = ON -slave_checkpoint_group = 512 -slave_checkpoint_period = 300 -slave_exec_mode = strict -slave_load_tmpdir = /data/mysql/tmp -slave_net_timeout = 4 -slave_parallel_type = LOGICAL_CLOCK -slave_parallel_workers = 8 -slave_pending_jobs_size_max = 1073741824 -slave_rows_search_algorithms = INDEX_SCAN,HASH_SCAN -slave_sql_verify_checksum = OFF -slave_type_conversions = -slow_launch_time = 2 -slow_query_log = OFF -slow_query_log_file = /data/mysql/log/slow.log -socket = /data/mysql/run/mysql.sock -sort_buffer_size = 868352 -sql_mode = NO_ENGINE_SUBSTITUTION -stored_program_cache = 256 -sync_binlog = 1 -sync_master_info = 10000 -sync_relay_log = 1 -sync_relay_log_info = 10000 -table_open_cache_instances = 16 -thread_cache_size = 100 -thread_stack = 262144 -tmp_table_size = 2097152 -tmpdir = /data/mysql/tmp -transaction_alloc_block_size = 8192 -transaction_isolation = REPEATABLE-READ -transaction_prealloc_size = 4096 -transaction_write_set_extraction = XXHASH64 -updatable_views_with_limit = YES -user = mysql -wait_timeout = 28800 - -[mysqld_safe] -pid_file = /data/mysql/run/mysql.pid \ No newline at end of file diff --git a/build/images/polardbx-clinic/Dockerfile b/build/images/polardbx-clinic/Dockerfile index 1d0757d..567d20c 100644 --- a/build/images/polardbx-clinic/Dockerfile +++ b/build/images/polardbx-clinic/Dockerfile @@ -12,8 +12,9 @@ # limitations under the License. # Build the manager binary +ARG IMAGE_SOURCE +FROM ${IMAGE_SOURCE}${IMAGE_SOURCE:+"/"}centos:7 -FROM centos:7 WORKDIR /root USER root COPY build/images/polardbx-clinic/diagnose.sh /root/diagnose.sh diff --git a/build/images/polardbx-clinic/install_tool.sh b/build/images/polardbx-clinic/install_tool.sh index ed6dc63..4d8a33d 100644 --- a/build/images/polardbx-clinic/install_tool.sh +++ b/build/images/polardbx-clinic/install_tool.sh @@ -14,6 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Remove mirrorlist.centos.org. +sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo +sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo +sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo + cat < str: r = '' @@ -41,7 +43,7 @@ def retag_image(src, dest): 'docker', 'tag', src, dest, ]) -def build_image_for(build_env: lib.BuildEnv, target: lib.BuildTarget, repo, tag) -> str: +def build_image_for(build_env: lib.BuildEnv, target: lib.BuildTarget, repo, tag, image_source) -> str: dockerfile = os.path.join(build_env.get_dockerfile_parent_path(target.image), 'Dockerfile') current_revision = build_env.current_git_revision_or_tag() @@ -67,6 +69,7 @@ def build_image_for(build_env: lib.BuildEnv, target: lib.BuildTarget, repo, tag) subprocess.check_call([ 'docker', 'build', '--network', 'host', '--build-arg', 'VERSION=' + version, + '--build-arg', 'IMAGE_SOURCE=' + image_source, '--platform', build_env.docker_build_platform(), '-t', image_name, '-f', dockerfile, @@ -75,7 +78,7 @@ def build_image_for(build_env: lib.BuildEnv, target: lib.BuildTarget, repo, tag) return image_name -def build_images(build_env: lib.BuildEnv, targets: [str] or None, repo, tag, *, also_latest=False) -> [str]: +def build_images(build_env: lib.BuildEnv, targets: [str] or None, repo, tag, image_source, *, also_latest=False) -> [str]: # Select targets to build targets = [t for t in build_env.select_targets(targets) if t.image] @@ -87,7 +90,7 @@ def build_images(build_env: lib.BuildEnv, targets: [str] or None, repo, tag, *, images = [] for t in targets: print('[%s] Start build...' % t.target) - image = build_image_for(build_env, t, repo, tag) + image = build_image_for(build_env, t, repo, tag, image_source) print('[%s] Built: %s' % (t.target, image)) if tag != 'latest' and also_latest: @@ -117,6 +120,7 @@ def push_image(image): parser.add_argument('targets', metavar='target', type=str, nargs='*', help='targets to build.') parser.add_argument('--push', dest='push', action='store_true', help='push to registry.') parser.add_argument('--also-latest', dest='also_latest', action='store_true', help='also tag to latest') + parser.add_argument('--image-source', dest='image_source', default=DEFAULT_IMAGE_SOURCE, help='custom docker source registry/namespace') args = parser.parse_args() images = build_images( @@ -124,6 +128,7 @@ def push_image(image): args.targets, args.repo, args.tag, + args.image_source, also_latest=args.also_latest, ) diff --git a/pkg/binlogtool/cmd/truncate.go b/pkg/binlogtool/cmd/truncate.go index 9f7c3ab..1b739f9 100644 --- a/pkg/binlogtool/cmd/truncate.go +++ b/pkg/binlogtool/cmd/truncate.go @@ -23,10 +23,13 @@ import ( "fmt" "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog" "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/event" + "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/spec" "github.com/alibaba/polardbx-operator/pkg/binlogtool/utils" "github.com/spf13/cobra" "io" "os" + "strconv" + "strings" ) var ( @@ -34,6 +37,7 @@ var ( binlogChecksum string truncateEndOffset string truncateEndTimestamp uint32 + truncateEndTSO uint64 outputBinlogFile string ) @@ -57,8 +61,8 @@ var truncateCmd = &cobra.Command{ binlog.WithScanMode(binlog.ScanModeRaw), } - if truncateEndOffset == "" && truncateEndTimestamp <= 0 { - return errors.New("end-offset or end-ts must be specified") + if truncateEndOffset == "" && truncateEndTimestamp <= 0 && truncateEndTSO <= 0 { + return errors.New("end-offset or end-ts or end-tso must be specified") } if outputBinlogFile == "" { @@ -101,19 +105,40 @@ var truncateCmd = &cobra.Command{ writer.WriteCommonHeader() for { - _, event, err := lazyScanner.Next() + _, ev, err := lazyScanner.Next() if err != nil { if err == binlog.EOF { break } return err } - lastEvent = event - if truncateEndTimestamp > 0 && event.EventHeader().EventTimestamp() > truncateEndTimestamp { + lastEvent = ev + if truncateEndTimestamp > 0 && ev.EventHeader().EventTimestamp() > truncateEndTimestamp { return nil } - writer.Write(event) + if truncateEndTSO > 0 && ev.EventHeader().EventTypeCode() == spec.ROWS_QUERY_LOG_EVENT { + queryEvent := ev.EventData().(event.RawLogEventData) + eventContent := string(queryEvent) + /** + TSO in cdc binlog is in rows query log event and as follows: + CTS::714859135699727161616796565716735180810000000000000000 + Notice: the first character in the event content is byte `1` not `C`, so I use eventContent[1:6] to + extract the prefix and then parse the first 19 chars to uint64. + */ + if strings.HasPrefix(eventContent[1:6], "CTS::") { + tso, err := strconv.ParseUint(eventContent[6:25], 10, 64) + if err != nil { + return err + } + + if tso > truncateEndTSO { + return nil + } + } + } + + writer.Write(ev) } return nil }), @@ -124,6 +149,7 @@ func init() { truncateCmd.Flags().StringVarP(&outputBinlogFile, "output", "o", "", "The output binlog after cut") truncateCmd.Flags().StringVar(&truncateEndOffset, "end-offset", "", "offset offset in bytes") truncateCmd.Flags().Uint32Var(&truncateEndTimestamp, "end-ts", 0, "end timestamp in seconds (compared with event header)") + truncateCmd.Flags().Uint64Var(&truncateEndTSO, "end-tso", 0, "end tso (compared with event rows query info)") rootCmd.AddCommand(truncateCmd) } diff --git a/pkg/hpfs/backupbinlog/start.go b/pkg/hpfs/backupbinlog/start.go index c61b2c4..c1928d5 100644 --- a/pkg/hpfs/backupbinlog/start.go +++ b/pkg/hpfs/backupbinlog/start.go @@ -2,6 +2,8 @@ package backupbinlog import ( . "github.com/alibaba/polardbx-operator/pkg/hpfs/config" + "github.com/pkg/errors" + "io/fs" "os" "path/filepath" "sigs.k8s.io/controller-runtime/pkg/log/zap" @@ -47,7 +49,9 @@ func StartAllWatchers() { infoFilepath := filepath.Join(watcherWorkDir, InfoFilename) _, err := os.Stat(infoFilepath) if err != nil { - logger.Error(err, "cannot stat file", "filepath", infoFilepath) + if !errors.Is(err, fs.ErrNotExist) { + logger.Error(err, "cannot stat file", "filepath", infoFilepath) + } continue } indexFilepath := filepath.Join(watcherWorkDir, IndexFilename) diff --git a/pkg/hpfs/backupbinlog/watcher.go b/pkg/hpfs/backupbinlog/watcher.go index a93d88d..d8508b1 100644 --- a/pkg/hpfs/backupbinlog/watcher.go +++ b/pkg/hpfs/backupbinlog/watcher.go @@ -466,16 +466,16 @@ func (w *Watcher) tryPurge(sqliteDb *sql.DB, mysqlDb *sql.DB, info Info, binlogN purgeBinlogNum = &binlogNums[countPurgeCnt-1] } expireTime := time.Now().Add(time.Duration(-info.LocalExpireLogSeconds) * time.Second) - for _, binlogNum := range binlogNums { + for i, binlogNum := range binlogNums { fileInfo, err := os.Stat(binlogNum.Filepath) if errors.Is(err, os.ErrNotExist) { continue } if fileInfo.ModTime().Before(expireTime) { if purgeBinlogNum == nil { - purgeBinlogNum = &binlogNum + purgeBinlogNum = &binlogNums[i] } else if binlogNum.Num > purgeBinlogNum.Num { - purgeBinlogNum = &binlogNum + purgeBinlogNum = &binlogNums[i] } } } diff --git a/pkg/hpfs/cpusetbind/manager.go b/pkg/hpfs/cpusetbind/manager.go index 6438500..fc46ceb 100644 --- a/pkg/hpfs/cpusetbind/manager.go +++ b/pkg/hpfs/cpusetbind/manager.go @@ -10,6 +10,7 @@ import ( "github.com/alibaba/polardbx-operator/pkg/hpfs/cpusetbind/cri" "github.com/alibaba/polardbx-operator/pkg/hpfs/cpusetbind/pool" cpusetbind "github.com/alibaba/polardbx-operator/pkg/hpfs/cpusetbind/system" + polarxJson "github.com/alibaba/polardbx-operator/pkg/util/json" "github.com/go-logr/logr" "github.com/google/uuid" v1 "k8s.io/api/core/v1" @@ -354,6 +355,12 @@ func (m *Manager) Start() error { return err } go func() { + defer func() { + err := recover() + if err != nil { + m.logger.Error(errors.New(polarxJson.Convert2JsonString(err)), "failed to init cpu bind") + } + }() for { select { case <-time.After(30 * time.Second): diff --git a/pkg/hpfs/cpusetbind/system/cpuinfo.go b/pkg/hpfs/cpusetbind/system/cpuinfo.go index c298aaf..b8c9bfc 100644 --- a/pkg/hpfs/cpusetbind/system/cpuinfo.go +++ b/pkg/hpfs/cpusetbind/system/cpuinfo.go @@ -8,7 +8,7 @@ import ( "strings" ) -const CpuInfoFilepath = "/proc/cpuinfo" +const CpuInfoFilepath = "/host/proc/cpuinfo" const CpuPhysicalIdFilepathFormat = "/sys/devices/system/cpu/cpu%d/topology/physical_package_id" const CpuCoreIdFilepathFormat = "/sys/devices/system/cpu/cpu%d/topology/core_id" diff --git a/pkg/hpfs/cpusetbind/system/proc.go b/pkg/hpfs/cpusetbind/system/proc.go index 1ebf3b9..bb20dcb 100644 --- a/pkg/hpfs/cpusetbind/system/proc.go +++ b/pkg/hpfs/cpusetbind/system/proc.go @@ -12,10 +12,10 @@ import ( "strings" ) -const DirectoryPath = "/proc" -const CmdLineFilepathFormat = "/proc/%d/cmdline" -const CommFilepathFormat = "/proc/%d/comm" -const EnvFilepathFormat = "/proc/%d/environ" +const DirectoryPath = "/host/proc" +const CmdLineFilepathFormat = "/host/proc/%d/cmdline" +const CommFilepathFormat = "/host/proc/%d/comm" +const EnvFilepathFormat = "/host/proc/%d/environ" const PodCmdParamPrefix = "-Dpod.id=" const NumaMapsFilepath = "/proc/%d/numa_maps" const NumaNodeNumAttrPattern = `N(\d+)=(\d+)` diff --git a/pkg/hpfs/filestream/flowcontrol.go b/pkg/hpfs/filestream/flowcontrol.go index 95dc153..0a3890a 100644 --- a/pkg/hpfs/filestream/flowcontrol.go +++ b/pkg/hpfs/filestream/flowcontrol.go @@ -116,7 +116,9 @@ func (f *FlowControlManger) LimitFlow(reader io.Reader, writer io.Writer, notify go func() { defer func() { obj := recover() - fmt.Println(obj, debug.Stack()) + if obj != nil { + fmt.Println(obj, string(debug.Stack())) + } }() defer wg.Done() for { diff --git a/pkg/meta/core/gms/manager.go b/pkg/meta/core/gms/manager.go index 8fbc90c..afe209a 100644 --- a/pkg/meta/core/gms/manager.go +++ b/pkg/meta/core/gms/manager.go @@ -53,6 +53,17 @@ const ( GrantCustomPrivilege GrantPrivilegeType = "custom" ) +type AccountType string + +const ( + AccountTypeUser AccountType = "0" + AccountTypeRole AccountType = "1" + AccountTypeDBA AccountType = "2" + AccountTypeSSO AccountType = "3" + AccountTypeAuditor AccountType = "4" + AccountTypeGod AccountType = "5" +) + // GrantOption which type GrantOption struct { // Type of grant. @@ -324,6 +335,9 @@ type Manager interface { // DeleteDBAccount deletes the specified account in cluster by directly deleting records in metadb. DeleteDBAccount(user string) error + // ModifyDBAccountType modify DB account type in metadb user_priv table if account_type fields exists. + ModifyDBAccountType(user string, accountType AccountType) error + // SyncAccountPasswd syncs the password of specified user in cluster by directly modifying records // in metadb. If the user not exists, it returns an error. SyncAccountPasswd(user, passwd string) error diff --git a/pkg/meta/core/gms/manager_impl.go b/pkg/meta/core/gms/manager_impl.go index 089538f..b3cfffa 100644 --- a/pkg/meta/core/gms/manager_impl.go +++ b/pkg/meta/core/gms/manager_impl.go @@ -1203,9 +1203,17 @@ func (meta *manager) CreateDBAccount(user, passwd string, grantOptions ...*Grant return meta.ExecuteStatementsAndNotify(insertStmt, notifyStmt) } +func (meta *manager) ModifyDBAccountType(user string, accountType AccountType) error { + modifyStmt := fmt.Sprintf("UPDATE user_priv SET account_type = '%s' WHERE user_name='%s'", string(accountType), user) + notifyStmt := meta.newNotifyStmt(clPrivilegeInfoDataId) + + // Execute the statements + return meta.ExecuteStatementsAndNotify(modifyStmt, notifyStmt) +} + func (meta *manager) DeleteDBAccount(user string) error { // Generate delete statement - deleteStmt := fmt.Sprintf("DELETE FROM user_priv WHERE user = '%s", user) + deleteStmt := fmt.Sprintf("DELETE FROM user_priv WHERE user = '%s'", user) notifyStmt := meta.newNotifyStmt(clPrivilegeInfoDataId) // Execute the statements diff --git a/pkg/operator/v1/polardbx/controllers/polardbxcluster_controller.go b/pkg/operator/v1/polardbx/controllers/polardbxcluster_controller.go index eb92c7d..9cf24e9 100644 --- a/pkg/operator/v1/polardbx/controllers/polardbxcluster_controller.go +++ b/pkg/operator/v1/polardbx/controllers/polardbxcluster_controller.go @@ -210,6 +210,7 @@ func (r *PolarDBXReconciler) newReconcileTask(rc *polardbxreconcile.Context, pol instancesteps.WaitUntilCNDeploymentsRolledOut, instancesteps.WaitUntilCDCDeploymentsRolledOut, instancesteps.WaitUntilColumnarDeploymentsRolledOut, + instancesteps.ModifyDBAAccountTypeIfNeeded, instancesteps.CreateFileStorage, )(task) diff --git a/pkg/operator/v1/polardbx/steps/instance/object.go b/pkg/operator/v1/polardbx/steps/instance/object.go index c44e3b8..676fe19 100644 --- a/pkg/operator/v1/polardbx/steps/instance/object.go +++ b/pkg/operator/v1/polardbx/steps/instance/object.go @@ -710,6 +710,44 @@ var CreateFileStorage = polardbxv1reconcile.NewStepBinder("CreateFileStorage", }, ) +var ModifyDBAAccountTypeIfNeeded = polardbxv1reconcile.NewStepBinder("ModifyDBAAccountTypeIfNeeded", + func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { + polardbx := rc.MustGetPolarDBX() + + mgr, err := rc.GetPolarDBXGMSManager() + if err != nil { + return flow.Error(err, "Unable to get GMS manager.") + } + + privileges := polardbx.Spec.Privileges + rootAccountDefined := false + for _, priv := range privileges { + if priv.Type != polardbxv1polardbx.Super { + continue + } + + if priv.Username == convention.RootAccount { + rootAccountDefined = true + } + + // Only super account need to set to DBA + err = mgr.ModifyDBAccountType(priv.Username, gms.AccountTypeDBA) + if err != nil { + return flow.Error(err, "Unable to modify account type.", "username", convention.RootAccount) + } + } + + if !rootAccountDefined { + mgr.ModifyDBAccountType(convention.RootAccount, gms.AccountTypeDBA) + if err != nil { + return flow.Error(err, "Unable to modify account type.", "username", convention.RootAccount) + } + } + + return flow.Pass() + }, +) + var CreateOrReconcileCNs = polardbxv1reconcile.NewStepBinder("CreateOrReconcileCNs", func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { return reconcileGroupedDeployments(rc, flow, polardbxmeta.RoleCN) diff --git a/pkg/operator/v1/xstore/meta/annotations.go b/pkg/operator/v1/xstore/meta/annotations.go index abd12a9..a970f3e 100644 --- a/pkg/operator/v1/xstore/meta/annotations.go +++ b/pkg/operator/v1/xstore/meta/annotations.go @@ -62,6 +62,7 @@ const ( AnnotationAutoRebuild = "xstore/auto-rebuild" AnnotationFlushLocal = "xstore/flushlocal" AnnotationFlushIp = "xstore/fluship" + AnnotationDeleteOnce = "xstore/delete-once" ) const ( diff --git a/pkg/operator/v1/xstore/steps/follower/job.go b/pkg/operator/v1/xstore/steps/follower/job.go index b3f3f36..0b5b28d 100644 --- a/pkg/operator/v1/xstore/steps/follower/job.go +++ b/pkg/operator/v1/xstore/steps/follower/job.go @@ -197,7 +197,7 @@ func JobArgFlushConsensusFunc(ctx JobContext) []string { learnerFlag = "--learner" } return []string{"-c", - "chown -R mysql:mysql /data/mysql && rm -fR /data/mysql/log/mysql_bin.* && /tools/xstore/current/venv/bin/python3 /tools/xstore/current/cli.py engine reset_meta --learner --recover-index-filepath=" + backupBinlogInfoFilepath + " " + learnerFlag, + "chown -R mysql:mysql /data/mysql && chown -R mysql:mysql /data-log/mysql && rm -fR /data/mysql/log/mysql_bin.* && /tools/xstore/current/venv/bin/python3 /tools/xstore/current/cli.py engine reset_meta --learner --recover-index-filepath=" + backupBinlogInfoFilepath + " " + learnerFlag, } } diff --git a/pkg/operator/v1/xstore/steps/follower/pod.go b/pkg/operator/v1/xstore/steps/follower/pod.go index e1176c1..e22647b 100644 --- a/pkg/operator/v1/xstore/steps/follower/pod.go +++ b/pkg/operator/v1/xstore/steps/follower/pod.go @@ -165,6 +165,14 @@ var TryLoadTargetPod = NewStepBinder("TryLoadTargetPod", func(rc *xstorev1reconc xstoremeta.LabelPod: pod.Name, })) rc.MarkChanged() + //mark pod to be deleted once + pod.SetAnnotations(k8shelper.PatchAnnotations(pod.GetAnnotations(), map[string]string{ + xstoremeta.AnnotationDeleteOnce: "1", + })) + err = rc.Client().Update(rc.BaseReconcileContext.Context(), &pod) + if err != nil { + return flow.RetryErr(err, "Failed to update rebuild pod xstore/delete-once Annotation") + } return flow.Continue("TryLoadTargetPod Success.") }) @@ -450,7 +458,7 @@ var WaitForTargetPodReady = NewStepBinder("WaitForTargetPodReady", func(rc *xsto return flow.RetryErr(err, "Failed to ge the pod", "podName", xStoreFollower.Spec.TargetPodName) } - if rebuildPod.Spec.NodeName != xStoreFollower.Status.RebuildNodeName { + if rebuildPod.GetAnnotations()[xstoremeta.AnnotationDeleteOnce] == "1" || rebuildPod.Spec.NodeName != xStoreFollower.Status.RebuildNodeName { err = rc.Client().Delete(rc.Context(), rebuildPod) if err != nil { return flow.RetryErr(ErrorFailDeletePod, "failed to delete pod", "pod name", rebuildPod.Name) diff --git a/pkg/operator/v1/xstore/steps/instance/engine_config.go b/pkg/operator/v1/xstore/steps/instance/engine_config.go index bba664b..861c980 100644 --- a/pkg/operator/v1/xstore/steps/instance/engine_config.go +++ b/pkg/operator/v1/xstore/steps/instance/engine_config.go @@ -62,6 +62,7 @@ var SyncEngineConfigMap = xstorev1reconcile.NewStepBinder("SyncEngineConfigMap", } xstore := rc.MustGetXStore() xstore.Status.ObservedConfig.Engine.Override = xstore.Spec.Config.Engine.Override.DeepCopy() + rc.MarkXStoreChanged() return flow.Continue("finish SyncEngineConfigMap") }, ) diff --git a/pkg/operator/v1/xstore/steps/instance/recreate.go b/pkg/operator/v1/xstore/steps/instance/recreate.go index e086852..b20b8db 100644 --- a/pkg/operator/v1/xstore/steps/instance/recreate.go +++ b/pkg/operator/v1/xstore/steps/instance/recreate.go @@ -82,6 +82,10 @@ func hpfsWriteResetMetaIndicate(ctx context.Context, hpfsClient hpfs.HpfsService func WhenNoPod(binders ...control.BindFunc) control.BindFunc { return xstorev1reconcile.NewStepIfBinder("WhenNoRightPod", func(rc *xstorev1reconcile.Context, log logr.Logger) (bool, error) { + xstore := rc.MustGetXStore() + if xstore.Spec.Readonly { + return false, nil + } pods, err := rc.GetXStorePods() if err != nil { return false, err From 24d2ce2398e6df6e54113f37b1130ea284b89f90 Mon Sep 17 00:00:00 2001 From: busu Date: Thu, 18 Jul 2024 14:22:46 +0800 Subject: [PATCH 2/2] release v1.6.2 --- .github/config/values.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/config/values.yaml b/.github/config/values.yaml index 0601f44..92ced42 100644 --- a/.github/config/values.yaml +++ b/.github/config/values.yaml @@ -3,4 +3,7 @@ clusterDefaults: images: galaxysql: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-sql galaxyengine: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-engine-2.0 - galaxycdc: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-cdc \ No newline at end of file + galaxycdc: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-cdc + +imagePullSecrets: + - name: github-ci \ No newline at end of file