summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/buildtool/execution_api/execution_service/operation_cache.cpp3
-rw-r--r--src/buildtool/execution_api/execution_service/operation_cache.hpp2
3 files changed, 3 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f2bcb20..f48f24fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,8 @@ A feature release on top of `1.2.0`, backwards compatible.
- Improved protability and update of the bundled dependencies.
- Various minor improvements and typo fixes in the documentation.
+- Fixed a race condition in an internal cache of `just execute` used for keeping
+ track of running operations.
## Release `1.2.0` (2023-08-25)
diff --git a/src/buildtool/execution_api/execution_service/operation_cache.cpp b/src/buildtool/execution_api/execution_service/operation_cache.cpp
index 7fccdd41..1502016e 100644
--- a/src/buildtool/execution_api/execution_service/operation_cache.cpp
+++ b/src/buildtool/execution_api/execution_service/operation_cache.cpp
@@ -19,13 +19,11 @@
#include "google/protobuf/timestamp.pb.h"
void OperationCache::GarbageCollection() {
- std::shared_lock slock{mutex_};
if (cache_.size() > (threshold_ << 1U)) {
std::vector<std::pair<std::string, ::google::longrunning::Operation>>
tmp;
tmp.reserve(cache_.size());
std::copy(cache_.begin(), cache_.end(), std::back_insert_iterator(tmp));
- slock.release();
std::sort(tmp.begin(), tmp.end(), [](auto const& x, auto const& y) {
::google::protobuf::Timestamp tx;
::google::protobuf::Timestamp ty;
@@ -35,7 +33,6 @@ void OperationCache::GarbageCollection() {
});
std::size_t deleted = 0;
- std::unique_lock ulock{mutex_};
for (auto const& [key, op] : tmp) {
if (op.done()) {
DropInternal(key);
diff --git a/src/buildtool/execution_api/execution_service/operation_cache.hpp b/src/buildtool/execution_api/execution_service/operation_cache.hpp
index 25ca49a7..2467add7 100644
--- a/src/buildtool/execution_api/execution_service/operation_cache.hpp
+++ b/src/buildtool/execution_api/execution_service/operation_cache.hpp
@@ -63,8 +63,8 @@ class OperationCache {
std::size_t threshold_{1U << kDefaultExponent};
void SetInternal(std::string const& action, Operation const& op) {
- GarbageCollection();
std::unique_lock lock{mutex_};
+ GarbageCollection();
cache_[action] = op;
}