Skip to content

Commit

Permalink
Add a fail point named force_change_all_blobs_to_read_only_once
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaqizho committed May 18, 2022
1 parent 43b25fc commit 4bd1f17
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dbms/src/Common/FailPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ std::unordered_map<String, std::shared_ptr<FailPointChannel>> 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) \
Expand Down
19 changes: 19 additions & 0 deletions dbms/src/Storages/Page/V3/BlobStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <Common/Checksum.h>
#include <Common/CurrentMetrics.h>
#include <Common/FailPoint.h>
#include <Common/Logger.h>
#include <Common/ProfileEvents.h>
#include <Common/StringUtils/StringUtils.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -870,6 +876,19 @@ std::vector<BlobFileId> BlobStore::getGCStats()
std::vector<BlobFileId> 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;
Expand Down

0 comments on commit 4bd1f17

Please sign in to comment.