@@ -56,8 +56,8 @@ namespace {
5656class [[nodiscard]] rdb_checkpoint final {
5757 public:
5858 rdb_checkpoint ()
59- : m_dir{
60- make_dir_name ( m_next_id.fetch_add (1 , std::memory_order_relaxed))} {}
59+ : m_prefix_dir{ make_dir_prefix_name (
60+ m_next_id.fetch_add (1 , std::memory_order_relaxed))} {}
6161
6262 ~rdb_checkpoint () {
6363 // Ignore the return value - at this point the clone operation is completing
@@ -68,9 +68,8 @@ class [[nodiscard]] rdb_checkpoint final {
6868 // Returns MySQL error code
6969 [[nodiscard]] int init () {
7070 assert (!m_active);
71- m_full_dir = make_dir_full_name (
72- m_dir.c_str (), m_next_sub_id.fetch_add (1 , std::memory_order_relaxed));
73- const auto result = myrocks::rocksdb_create_checkpoint (m_full_dir.c_str ());
71+ m_dir = make_dir_name (m_prefix_dir, m_next_sub_id++);
72+ const auto result = myrocks::rocksdb_create_checkpoint (m_dir.c_str ());
7473 m_active = (result == HA_EXIT_SUCCESS);
7574 return m_active ? 0 : ER_INTERNAL_ERROR;
7675 }
@@ -79,22 +78,21 @@ class [[nodiscard]] rdb_checkpoint final {
7978 [[nodiscard]] int cleanup () {
8079 if (!m_active) return 0 ;
8180 m_active = false ;
82- return myrocks::rocksdb_remove_checkpoint (m_full_dir.c_str ()) ==
83- HA_EXIT_SUCCESS
81+ return myrocks::rocksdb_remove_checkpoint (m_dir.c_str ()) == HA_EXIT_SUCCESS
8482 ? 0
8583 : ER_INTERNAL_ERROR;
8684 }
8785
8886 [[nodiscard]] constexpr const std::string &get_dir () const noexcept {
8987 assert (m_active);
90- return m_full_dir ;
88+ return m_dir ;
9189 }
9290
9391 [[nodiscard]] std::string path (const std::string &file_name) const {
9492 // We might be calling this for inactive checkpoint too, if the donor is in
9593 // the middle of a checkpoint roll. The caller will handle any ENOENTs as
9694 // needed.
97- return myrocks::rdb_concat_paths (m_full_dir , file_name);
95+ return myrocks::rdb_concat_paths (m_dir , file_name);
9896 }
9997
10098 rdb_checkpoint (const rdb_checkpoint &) = delete ;
@@ -103,17 +101,17 @@ class [[nodiscard]] rdb_checkpoint final {
103101 rdb_checkpoint &operator =(rdb_checkpoint &&) = delete ;
104102
105103 private:
106- const std::string m_dir ;
104+ const std::string m_prefix_dir ;
107105
108- std::string m_full_dir ;
106+ std::string m_dir ;
109107
110108 bool m_active = false ;
111109
112110 static std::atomic<std::uint64_t > m_next_id;
113111
114- std::atomic<std:: uint64_t > m_next_sub_id{ 1 } ;
112+ std::uint64_t m_next_sub_id = 1 ;
115113
116- [[nodiscard]] static std::string make_dir_name (std::uint64_t id) {
114+ [[nodiscard]] static std::string make_dir_prefix_name (std::uint64_t id) {
117115 const auto base_str = myrocks::clone::checkpoint_base_dir ();
118116 const auto id_str = std::to_string (id);
119117 std::string result;
@@ -128,14 +126,14 @@ class [[nodiscard]] rdb_checkpoint final {
128126 return result;
129127 }
130128
131- [[nodiscard]] static std::string make_dir_full_name (std::string base_dir,
132- std::uint64_t id) {
129+ [[nodiscard]] static std::string make_dir_name (
130+ const std::string &dir_name_prefix, std::uint64_t id) {
133131 const auto id_str = std::to_string (id);
134132 std::string result;
135- result.reserve (base_dir .length () + id_str.length () +
133+ result.reserve (dir_name_prefix .length () + id_str.length () +
136134 1 ); // +1 for '-', the trailing
137135 // '\0' is accounted by the sizeof.
138- result = base_dir ;
136+ result = dir_name_prefix ;
139137 result += ' -' ;
140138 result += id_str;
141139 return result;
0 commit comments