Skip to content

Commit 3df1e1c

Browse files
zhijunfurobertnishihara
authored andcommitted
Add missing lock in FreeObjects of object buffer pool (#3647)
Object manager uses multi-threading for transferring objects between different nodes, the plasma client used in object_buffer_pool_ needs to be protected by lock. We have met crashes caused by missing lock in FreeObjects() interface, this PR fixes that issue.
1 parent c59b506 commit 3df1e1c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ray/object_manager/object_buffer_pool.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,12 @@ void ObjectBufferPool::FreeObjects(const std::vector<ObjectID> &object_ids) {
192192
for (const auto &id : object_ids) {
193193
plasma_ids.push_back(id.to_plasma_id());
194194
}
195+
std::lock_guard<std::mutex> lock(pool_mutex_);
195196
ARROW_CHECK_OK(store_client_.Delete(plasma_ids));
196197
}
197198

198199
std::string ObjectBufferPool::DebugString() const {
200+
std::lock_guard<std::mutex> lock(pool_mutex_);
199201
std::stringstream result;
200202
result << "BufferPool:";
201203
result << "\n- get buffer state map size: " << get_buffer_state_.size();

src/ray/object_manager/object_buffer_pool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class ObjectBufferPool {
182182

183183
/// Mutex on public methods for thread-safe operations on
184184
/// get_buffer_state_, create_buffer_state_, and store_client_.
185-
std::mutex pool_mutex_;
185+
mutable std::mutex pool_mutex_;
186186
/// Determines the maximum chunk size to be transferred by a single thread.
187187
const uint64_t default_chunk_size_;
188188
/// The state of a buffer that's currently being used.

0 commit comments

Comments
 (0)