Skip to content

Commit

Permalink
fix thread sanitizer alarms (#13522)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Jan 19, 2025
1 parent a096daa commit 6dae4df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ TString TFetchingScript::DebugString() const {
return "";
}
sb << "{branch:" << BranchName << ";";
if (FinishInstant && StartInstant) {
sb << "duration:" << *FinishInstant - *StartInstant << ";";
if (AtomicGet(FinishInstant) && AtomicGet(StartInstant)) {
sb << "duration:" << AtomicGet(FinishInstant) - AtomicGet(StartInstant) << ";";
}

sb << "steps_10Ms:[" << sbBranch << "]}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class TFetchingScript {
private:
YDB_ACCESSOR(TString, BranchName, "UNDEFINED");
std::vector<std::shared_ptr<IFetchingStep>> Steps;
std::optional<TMonotonic> StartInstant;
std::optional<TMonotonic> FinishInstant;
TAtomic StartInstant;
TAtomic FinishInstant;

public:
TFetchingScript(const TSpecialReadContext& context);
Expand All @@ -122,14 +122,12 @@ class TFetchingScript {
}

void AddStepDuration(const ui32 index, const TDuration d) {
FinishInstant = TMonotonic::Now();
AtomicSet(FinishInstant, TMonotonic::Now().MicroSeconds());
GetStep(index)->AddDuration(d);
}

void OnExecute() {
if (!StartInstant) {
StartInstant = TMonotonic::Now();
}
AtomicCas(&StartInstant, TMonotonic::Now().MicroSeconds(), 0);
}

TString DebugString() const;
Expand Down

0 comments on commit 6dae4df

Please sign in to comment.