Skip to content

Commit ef03968

Browse files
author
Paweł Andruszkiewicz
committed
BUG#35983655 Report time overhead of checksum not only in the log
If the checksum option is enabled, dump/load/copy utilities will display time it took to compute/verify the checksum. Change-Id: Id6b1f227fd6d407a983737bf281db63ca774cf84 (cherry picked from commit 41eb66384d34e0a07806814ed39e308f7ccbb8fa)
1 parent e4caa6e commit ef03968

10 files changed

+57
-20
lines changed

modules/util/dump/dumper.cc

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,8 @@ class Dumper::Table_worker final {
950950
log_debug("%sComputing checksum of %s (%s)", m_log_id.c_str(),
951951
task.name.c_str(), task.id.c_str());
952952

953+
m_dumper->checksum_task_started();
954+
953955
if (Dry_run::DISABLED == m_dumper->m_options.dry_run_mode()) {
954956
task.checksum->compute(
955957
m_session,
@@ -2003,31 +2005,41 @@ void Dumper::do_run() {
20032005
create_schema_ddl_tasks();
20042006
create_table_tasks();
20052007

2006-
if (!m_options.is_dry_run() && !m_worker_interrupt) {
2007-
auto msg = "Running data dump using " +
2008-
std::to_string(m_options.threads()) + " thread";
2008+
if (!m_worker_interrupt) {
2009+
std::string msg;
20092010

2010-
if (m_options.threads() > 1) {
2011-
msg += 's';
2012-
}
2011+
if (!m_options.is_dry_run()) {
2012+
msg = "Running data dump using " + std::to_string(m_options.threads()) +
2013+
" thread";
2014+
2015+
if (m_options.threads() > 1) {
2016+
msg += 's';
2017+
}
20132018

2014-
msg += '.';
2019+
msg += '.';
2020+
}
20152021

20162022
if (m_checksum) {
2017-
msg += " Checksumming enabled.";
2023+
if (!msg.empty()) {
2024+
msg += ' ';
2025+
}
2026+
2027+
msg += "Checksumming enabled.";
20182028
}
20192029

2020-
current_console()->print_status(msg);
2030+
if (!msg.empty()) {
2031+
current_console()->print_status(msg);
2032+
}
20212033

2022-
if (m_options.show_progress() && m_options.dump_data()) {
2034+
if (!m_options.is_dry_run() && m_options.show_progress() &&
2035+
m_options.dump_data()) {
20232036
current_console()->print_note(
20242037
"Progress information uses estimated values and may not be "
20252038
"accurate.");
20262039
}
20272040
}
20282041

20292042
initialize_throughput_progress();
2030-
initialize_checksum_progress();
20312043

20322044
maybe_push_shutdown_tasks();
20332045
wait_for_all_tasks();
@@ -2918,6 +2930,14 @@ void Dumper::data_task_finished() {
29182930
}
29192931
}
29202932

2933+
void Dumper::checksum_task_started() {
2934+
bool expected = false;
2935+
2936+
if (m_checksum_started.compare_exchange_strong(expected, true)) {
2937+
initialize_checksum_progress();
2938+
}
2939+
}
2940+
29212941
void Dumper::checksum_task_finished() { ++m_checksum_tasks_completed; }
29222942

29232943
void Dumper::wait_for_all_tasks() {
@@ -3145,6 +3165,7 @@ void Dumper::create_table_tasks() {
31453165
m_chunking_tasks_completed = 0;
31463166
m_data_tasks_total = 0;
31473167
m_data_tasks_completed = 0;
3168+
m_checksum_started = false;
31483169
m_checksum_tasks_total = 0;
31493170
m_checksum_tasks_completed = 0;
31503171

@@ -3921,6 +3942,11 @@ void Dumper::summarize() const {
39213942
m_data_dump_stage->duration().to_string());
39223943
}
39233944

3945+
if (m_checksum_stage) {
3946+
console->print_status("Checksum duration: " +
3947+
m_checksum_stage->duration().to_string());
3948+
}
3949+
39243950
console->print_status("Total duration: " +
39253951
m_progress_thread.duration().to_string());
39263952

@@ -4062,7 +4088,7 @@ void Dumper::initialize_checksum_progress() {
40624088
config.total = [this]() { return m_checksum_tasks_total.load(); };
40634089
config.is_total_known = [this]() { return all_tasks_produced(); };
40644090

4065-
m_current_stage =
4091+
m_current_stage = m_checksum_stage =
40664092
m_progress_thread.start_stage("Computing checksum", std::move(config));
40674093
}
40684094

modules/util/dump/dumper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class Dumper {
256256

257257
void data_task_finished();
258258

259+
void checksum_task_started();
260+
259261
void checksum_task_finished();
260262

261263
void wait_for_all_tasks();
@@ -484,6 +486,7 @@ class Dumper {
484486
std::atomic<uint64_t> m_chunking_tasks_completed;
485487
std::atomic<uint64_t> m_data_tasks_total;
486488
std::atomic<uint64_t> m_data_tasks_completed;
489+
std::atomic<bool> m_checksum_started;
487490
std::atomic<uint64_t> m_checksum_tasks_total;
488491
std::atomic<uint64_t> m_checksum_tasks_completed;
489492
std::atomic<bool> m_main_thread_finished_producing_chunking_tasks;
@@ -496,6 +499,7 @@ class Dumper {
496499
mutable Progress_thread m_progress_thread;
497500
mutable Progress_thread::Stage *m_current_stage = nullptr;
498501
Progress_thread::Stage *m_data_dump_stage = nullptr;
502+
Progress_thread::Stage *m_checksum_stage = nullptr;
499503

500504
shcore::Synchronized_queue<std::shared_ptr<mysqlshdk::db::ISession>>
501505
m_session_pool;

modules/util/load/dump_loader.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,8 +2035,12 @@ void Dump_loader::show_summary() {
20352035

20362036
if (!m_options.dry_run()) {
20372037
if (m_checksum_tasks_completed) {
2038+
assert(m_checksum_tables_stage);
20382039
console->print_info(shcore::str_format(
2039-
"%" PRIu64 " checksums were verified.", m_checksum_tasks_completed));
2040+
"%" PRIu64 " checksums were verified in %s.",
2041+
m_checksum_tasks_completed,
2042+
format_seconds(m_checksum_tables_stage->duration().seconds(), false)
2043+
.c_str()));
20402044
}
20412045

20422046
if (m_checksum_errors) {

unittest/scripts/auto/py_shell/scripts/util_copy_instance_norecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def setup_db(account):
664664

665665
#@<> WL15887-TSFR_4_1 - note about strip_definers {not __dbug_off and VER(>=8.2.0)}
666666
EXPECT_SUCCESS(__sandbox_uri2, { "compatibility": [ "strip_definers" ], "dryRun": True, "includeSchemas": [ schema_name ], "users": False, "showProgress": False })
667-
EXPECT_STDOUT_CONTAINS(f"NOTE: The 'targetVersion' option is set to {__mysh_version_no_extra}. This version supports the SET_ANY_DEFINER privilege, using the 'strip_definers' compatibility option is unnecessary.")
667+
EXPECT_STDOUT_CONTAINS(f"NOTE: The 'targetVersion' option is set to {__version}. This version supports the SET_ANY_DEFINER privilege, using the 'strip_definers' compatibility option is unnecessary.")
668668

669669
#@<> WL15887-TSFR_5_1 - user/role with SET_ANY_DEFINER {not __dbug_off and VER(>=8.2.0)}
670670
for account in account_names:

unittest/scripts/auto/py_shell/scripts/util_copy_schemas_norecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def setup_db(account):
612612

613613
#@<> WL15887-TSFR_4_1 - note about strip_definers {not __dbug_off and VER(>=8.2.0)}
614614
EXPECT_SUCCESS(__sandbox_uri2, { "compatibility": [ "strip_definers" ], "dryRun": True, "showProgress": False }, schemas = [ schema_name ])
615-
EXPECT_STDOUT_CONTAINS(f"NOTE: The 'targetVersion' option is set to {__mysh_version_no_extra}. This version supports the SET_ANY_DEFINER privilege, using the 'strip_definers' compatibility option is unnecessary.")
615+
EXPECT_STDOUT_CONTAINS(f"NOTE: The 'targetVersion' option is set to {__version}. This version supports the SET_ANY_DEFINER privilege, using the 'strip_definers' compatibility option is unnecessary.")
616616

617617
#@<> WL15887 - cleanup {not __dbug_off and VER(>=8.2.0)}
618618
src_session.run_sql("DROP SCHEMA IF EXISTS !;", [schema_name])

unittest/scripts/auto/py_shell/scripts/util_copy_tables_norecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def setup_db(account):
534534

535535
#@<> WL15887-TSFR_4_1 - note about strip_definers {not __dbug_off and VER(>=8.2.0)}
536536
EXPECT_SUCCESS(__sandbox_uri2, { "compatibility": [ "strip_definers" ], "dryRun": True, "showProgress": False }, schema = schema_name , tables = test_tables)
537-
EXPECT_STDOUT_CONTAINS(f"NOTE: The 'targetVersion' option is set to {__mysh_version_no_extra}. This version supports the SET_ANY_DEFINER privilege, using the 'strip_definers' compatibility option is unnecessary.")
537+
EXPECT_STDOUT_CONTAINS(f"NOTE: The 'targetVersion' option is set to {__version}. This version supports the SET_ANY_DEFINER privilege, using the 'strip_definers' compatibility option is unnecessary.")
538538

539539
#@<> WL15887 - cleanup {not __dbug_off and VER(>=8.2.0)}
540540
src_session.run_sql("DROP SCHEMA IF EXISTS !;", [schema_name])

unittest/scripts/auto/py_shell/scripts/util_dump_and_load_norecord.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,8 @@ def TEST_BOOL_OPTION(option):
29702970
# WL15947-TSFR_2_4_3 - load an empty table
29712971
wipeout_server(session2)
29722972
EXPECT_NO_THROWS(lambda: util.load_dump(dump_dir, { "checksum": True, "resetProgress": True, "showProgress": False }))
2973+
# BUG#35983655 - display duration of checksum verification
2974+
EXPECT_STDOUT_CONTAINS(" checksums were verified in ")
29732975

29742976
# WL15947-TSFR_2_4_2 - checksum existing tables without loading the data
29752977
# this throws because both dumps were created with different contents (one had `where` option)

unittest/scripts/auto/py_shell/scripts/util_dump_instance_norecord.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,7 +3855,8 @@ def setup_db():
38553855
#@<> WL15947-TSFR_1_2_1_1 - checksum option set to true
38563856
EXPECT_SUCCESS([ schema_name ], test_output_absolute, { "checksum": True, "showProgress": False })
38573857
# checksums are generated
3858-
EXPECT_STDOUT_CONTAINS("Checksum")
3858+
# BUG#35983655 - display duration of checksum operation
3859+
EXPECT_STDOUT_CONTAINS("Checksum duration:")
38593860
# file is written
38603861
EXPECT_TRUE(os.path.isfile(checksum_file))
38613862

@@ -3952,7 +3953,7 @@ def setup_db():
39523953

39533954
#@<> WL15947 - dry run
39543955
EXPECT_SUCCESS([ schema_name ], test_output_absolute, { "dryRun": True, "checksum": True, "includeTables": [ quote_identifier(schema_name, test_table_unique_null) ], "showProgress": False })
3955-
EXPECT_STDOUT_CONTAINS("Computing checksum...")
3956+
EXPECT_STDOUT_CONTAINS("Checksumming enabled.")
39563957

39573958
#@<> WL15947 - cleanup
39583959
session.run_sql("DROP SCHEMA IF EXISTS !;", [schema_name])

unittest/scripts/auto/py_shell/scripts/util_dump_schemas_norecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ def setup_db():
27412741

27422742
#@<> WL15947 - dry run
27432743
EXPECT_SUCCESS([ schema_name ], test_output_absolute, { "dryRun": True, "checksum": True, "includeTables": [ quote_identifier(schema_name, test_table_unique_null) ], "showProgress": False })
2744-
EXPECT_STDOUT_CONTAINS("Computing checksum...")
2744+
EXPECT_STDOUT_CONTAINS("Checksumming enabled.")
27452745

27462746
#@<> WL15947 - cleanup
27472747
session.run_sql("DROP SCHEMA IF EXISTS !;", [schema_name])

unittest/scripts/auto/py_shell/scripts/util_dump_tables_norecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ def setup_db():
34363436

34373437
#@<> WL15947 - dry run
34383438
EXPECT_SUCCESS(schema_name, [ test_table_unique_null ], test_output_absolute, { "dryRun": True, "checksum": True, "showProgress": False })
3439-
EXPECT_STDOUT_CONTAINS("Computing checksum...")
3439+
EXPECT_STDOUT_CONTAINS("Checksumming enabled.")
34403440

34413441
#@<> WL15947 - cleanup
34423442
session.run_sql("DROP SCHEMA IF EXISTS !;", [schema_name])

0 commit comments

Comments
 (0)