Copilot commented on code in PR #13616:
URL: https://github.com/apache/trafficserver/pull/13616#discussion_r3917400994
##########
src/tsutil/Metrics.cc:
##########
@@ -73,6 +73,11 @@ Metrics::Storage::create(std::string_view name, const
MetricType type)
auto it = _lookups.find(name);
if (it != _lookups.end()) {
+ // Re-creating a name is how an unlisted metric is relisted: same slot,
same atomic, and
+ // whatever value it accumulated while it was out of the listing. A name
in _lookups always
+ // names an allocated slot, so this cannot fail.
+ set_listed(it->second, true);
+
Review Comment:
FlagStorage uses std::atomic<uint8_t>, whose default constructor does not
initialize the stored value. Since listed()/set_listed() read these flags for
allocated slots, a newly created metric can end up "unlisted"
nondeterministically unless the flag byte is explicitly initialized when the
slot is allocated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]