@@ -48,40 +48,57 @@ struct UnavailableRegions
4848 , is_wn_disagg_read(is_wn_disagg_read_)
4949 {}
5050
51- size_t size () const { return unavailable_ids .size (); }
51+ size_t size () const { return ids .size (); }
5252
53- bool empty () const { return unavailable_ids .empty (); }
53+ bool empty () const { return ids .empty (); }
5454
55- bool contains (RegionID region_id) const { return unavailable_ids .contains (region_id); }
55+ bool contains (RegionID region_id) const { return ids .contains (region_id); }
5656
57- void addStatus (RegionID region_id , RegionException::RegionReadStatus status_, std::string && extra_msg_)
57+ void addStatus (RegionID id , RegionException::RegionReadStatus status_, std::string && extra_msg_)
5858 {
59- unavailable_ids[region_id] = UnavailableDesc{status_, std::move (extra_msg_)};
59+ status = status_;
60+ ids.emplace (id);
61+ extra_msg = std::move (extra_msg_);
6062 }
6163
6264 void addRegionLock (RegionID region_id_, LockInfoPtr && region_lock_)
6365 {
6466 region_locks.emplace_back (region_id_, std::move (region_lock_));
65- unavailable_ids[ region_id_] = UnavailableDesc{RegionException::RegionReadStatus::MEET_LOCK, " " } ;
67+ ids. emplace ( region_id_) ;
6668 }
6769
6870 void tryThrowRegionException ();
6971
7072 void addRegionWaitIndexTimeout (RegionID region_id, UInt64 index_to_wait, UInt64 current_applied_index);
7173
72- String toDebugString (size_t num_show) const ;
74+ String toDebugString () const
75+ {
76+ FmtBuffer buffer;
77+ buffer.append (" {ids=[" );
78+ buffer.joinStr (
79+ ids.begin (),
80+ ids.end (),
81+ [](const auto & v, FmtBuffer & f) { f.fmtAppend (" {}" , v); },
82+ " |" );
83+ buffer.append (" ] locks=" );
84+ buffer.append (" [" );
85+ buffer.joinStr (
86+ region_locks.begin (),
87+ region_locks.end (),
88+ [](const auto & v, FmtBuffer & f) { f.fmtAppend (" {}({})" , v.first , v.second ->DebugString ()); },
89+ " |" );
90+ buffer.append (" ]}" );
91+ return buffer.toString ();
92+ }
7393
7494private:
7595 const bool batch_cop;
7696 const bool is_wn_disagg_read;
7797
78- struct UnavailableDesc
79- {
80- RegionException::RegionReadStatus s;
81- std::string extra_msg;
82- };
83- std::unordered_map<RegionID, UnavailableDesc> unavailable_ids;
98+ RegionException::UnavailableRegions ids;
8499 std::vector<std::pair<RegionID, LockInfoPtr>> region_locks;
100+ RegionException::RegionReadStatus status{RegionException::RegionReadStatus::NOT_FOUND};
101+ std::string extra_msg;
85102};
86103
87104using RegionsReadIndexResult = std::unordered_map<RegionID, kvrpcpb::ReadIndexResponse>;
0 commit comments