From 4bd1f1737d51a9a21a9f46756398ad30bc7ddc96 Mon Sep 17 00:00:00 2001 From: jiaqizho Date: Wed, 18 May 2022 16:54:53 +0800 Subject: [PATCH 1/2] Add a fail point named force_change_all_blobs_to_read_only_once --- dbms/src/Common/FailPoint.cpp | 3 ++- dbms/src/Storages/Page/V3/BlobStore.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dbms/src/Common/FailPoint.cpp b/dbms/src/Common/FailPoint.cpp index 602a86642fb..2712ba0238b 100644 --- a/dbms/src/Common/FailPoint.cpp +++ b/dbms/src/Common/FailPoint.cpp @@ -65,7 +65,8 @@ std::unordered_map> FailPointHelper::f M(exception_when_read_from_log) \ M(exception_mpp_hash_build) \ M(exception_before_drop_segment) \ - M(exception_after_drop_segment) + M(exception_after_drop_segment) \ + M(force_change_all_blobs_to_read_only_once) #define APPLY_FOR_FAILPOINTS(M) \ M(force_set_page_file_write_errno) \ diff --git a/dbms/src/Storages/Page/V3/BlobStore.cpp b/dbms/src/Storages/Page/V3/BlobStore.cpp index 3ed1d1a69b1..ef370b7bd26 100644 --- a/dbms/src/Storages/Page/V3/BlobStore.cpp +++ b/dbms/src/Storages/Page/V3/BlobStore.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,11 @@ extern const int LOGICAL_ERROR; extern const int CHECKSUM_DOESNT_MATCH; } // namespace ErrorCodes +namespace FailPoints +{ +extern const char force_change_all_blobs_to_read_only_once[]; +} // namespace FailPoints + namespace PS::V3 { static constexpr bool BLOBSTORE_CHECKSUM_ON_READ = true; @@ -870,6 +876,19 @@ std::vector BlobStore::getGCStats() std::vector blob_need_gc; BlobStoreGCInfo blobstore_gc_info; + fiu_do_on(FailPoints::force_change_all_blobs_to_read_only_once, + { + for (const auto & [path, stats] : stats_list) + { + (void)path; + for (const auto & stat : stats) + { + stat->changeToReadOnly(); + } + } + LOG_FMT_WARNING(log, "enabled force_change_all_blobs_to_read_only_once. All of BlobStat turn to READ-ONLY"); + }); + for (const auto & [path, stats] : stats_list) { (void)path; From 512d34907cee89da6ca23a9def939aa125bcb3aa Mon Sep 17 00:00:00 2001 From: jiaqizho Date: Wed, 18 May 2022 18:01:08 +0800 Subject: [PATCH 2/2] change once to always --- dbms/src/Common/FailPoint.cpp | 6 +++--- dbms/src/Storages/Page/V3/BlobStore.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dbms/src/Common/FailPoint.cpp b/dbms/src/Common/FailPoint.cpp index 2712ba0238b..a276e20670e 100644 --- a/dbms/src/Common/FailPoint.cpp +++ b/dbms/src/Common/FailPoint.cpp @@ -65,8 +65,7 @@ std::unordered_map> FailPointHelper::f M(exception_when_read_from_log) \ M(exception_mpp_hash_build) \ M(exception_before_drop_segment) \ - M(exception_after_drop_segment) \ - M(force_change_all_blobs_to_read_only_once) + M(exception_after_drop_segment) #define APPLY_FOR_FAILPOINTS(M) \ M(force_set_page_file_write_errno) \ @@ -83,7 +82,8 @@ std::unordered_map> FailPointHelper::f M(force_no_local_region_for_mpp_task) \ M(force_remote_read_for_batch_cop) \ M(force_context_path) \ - M(force_slow_page_storage_snapshot_release) + M(force_slow_page_storage_snapshot_release) \ + M(force_change_all_blobs_to_read_only) #define APPLY_FOR_FAILPOINTS_ONCE_WITH_CHANNEL(M) \ M(pause_with_alter_locks_acquired) \ diff --git a/dbms/src/Storages/Page/V3/BlobStore.cpp b/dbms/src/Storages/Page/V3/BlobStore.cpp index ef370b7bd26..91945d2a23a 100644 --- a/dbms/src/Storages/Page/V3/BlobStore.cpp +++ b/dbms/src/Storages/Page/V3/BlobStore.cpp @@ -51,7 +51,7 @@ extern const int CHECKSUM_DOESNT_MATCH; namespace FailPoints { -extern const char force_change_all_blobs_to_read_only_once[]; +extern const char force_change_all_blobs_to_read_only[]; } // namespace FailPoints namespace PS::V3 @@ -876,7 +876,7 @@ std::vector BlobStore::getGCStats() std::vector blob_need_gc; BlobStoreGCInfo blobstore_gc_info; - fiu_do_on(FailPoints::force_change_all_blobs_to_read_only_once, + fiu_do_on(FailPoints::force_change_all_blobs_to_read_only, { for (const auto & [path, stats] : stats_list) { @@ -886,7 +886,7 @@ std::vector BlobStore::getGCStats() stat->changeToReadOnly(); } } - LOG_FMT_WARNING(log, "enabled force_change_all_blobs_to_read_only_once. All of BlobStat turn to READ-ONLY"); + LOG_FMT_WARNING(log, "enabled force_change_all_blobs_to_read_only. All of BlobStat turn to READ-ONLY"); }); for (const auto & [path, stats] : stats_list)