Skip to content

Commit fb830d1

Browse files
authored
[core] Fix all gcs variable shadowing (#51704)
Signed-off-by: dentiny <dentinyhao@gmail.com>
1 parent 5544552 commit fb830d1

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,8 @@ pyx_library(
30543054
# shared lib, see python/ray/__init__.py.
30553055
cc_kwargs = dict(
30563056
srcs = PYX_SRCS,
3057-
copts = COPTS + PYX_COPTS,
3057+
# cython code is auto-generated, which is out of our control.
3058+
copts = COPTS + PYX_COPTS + ["-Wno-shadow"],
30583059
# see https://github.com/tensorflow/tensorflow/blob/r2.1/tensorflow/lite/BUILD#L444
30593060
linkopts = select({
30603061
"@platforms//os:osx": [

cpp/src/ray/runtime/task/task_executor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ void TaskExecutor::Invoke(
335335
}
336336
} catch (std::exception &e) {
337337
auto result = PackError(e.what());
338-
auto data = std::make_shared<msgpack::sbuffer>(std::move(result));
339-
runtime->Put(std::move(data), task_spec.ReturnId(0));
338+
auto result_data = std::make_shared<msgpack::sbuffer>(std::move(result));
339+
runtime->Put(std::move(result_data), task_spec.ReturnId(0));
340340
}
341341
}
342342

src/ray/gcs/gcs_server/gcs_job_manager.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,27 +357,27 @@ void GcsJobManager::HandleGetAllJobInfo(rpc::GetAllJobInfoRequest request,
357357
num_finished_tasks->fetch_add(job_count) + job_count;
358358
try_send_reply(updated_finished_tasks);
359359
} else {
360-
for (int i = 0; i < reply->job_info_list_size(); i++) {
361-
const auto &data = reply->job_info_list(i);
360+
for (int jj = 0; jj < reply->job_info_list_size(); jj++) {
361+
const auto &data = reply->job_info_list(jj);
362362
auto job_id = JobID::FromBinary(data.job_id());
363363
WorkerID worker_id = WorkerID::FromBinary(data.driver_address().worker_id());
364364

365365
// If job is dead, no need to get.
366366
if (data.is_dead()) {
367-
reply->mutable_job_info_list(i)->set_is_running_tasks(false);
367+
reply->mutable_job_info_list(jj)->set_is_running_tasks(false);
368368
core_worker_clients_.Disconnect(worker_id);
369369
size_t updated_finished_tasks = num_finished_tasks->fetch_add(1) + 1;
370370
try_send_reply(updated_finished_tasks);
371371
} else {
372372
// Get is_running_tasks from the core worker for the driver.
373373
auto client = core_worker_clients_.GetOrConnect(data.driver_address());
374-
auto request = std::make_unique<rpc::NumPendingTasksRequest>();
374+
auto pending_task_req = std::make_unique<rpc::NumPendingTasksRequest>();
375375
constexpr int64_t kNumPendingTasksRequestTimeoutMs = 1000;
376376
RAY_LOG(DEBUG) << "Send NumPendingTasksRequest to worker " << worker_id
377377
<< ", timeout " << kNumPendingTasksRequestTimeoutMs << " ms.";
378378
client->NumPendingTasks(
379-
std::move(request),
380-
[job_id, worker_id, reply, i, num_finished_tasks, try_send_reply](
379+
std::move(pending_task_req),
380+
[job_id, worker_id, reply, jj, num_finished_tasks, try_send_reply](
381381
const Status &status,
382382
const rpc::NumPendingTasksReply &num_pending_tasks_reply) {
383383
RAY_LOG(DEBUG).WithField(worker_id)
@@ -386,10 +386,11 @@ void GcsJobManager::HandleGetAllJobInfo(rpc::GetAllJobInfoRequest request,
386386
RAY_LOG(WARNING).WithField(job_id).WithField(worker_id)
387387
<< "Failed to get num_pending_tasks from core worker: " << status
388388
<< ", is_running_tasks is unset.";
389-
reply->mutable_job_info_list(i)->clear_is_running_tasks();
389+
reply->mutable_job_info_list(jj)->clear_is_running_tasks();
390390
} else {
391391
bool is_running_tasks = num_pending_tasks_reply.num_pending_tasks() > 0;
392-
reply->mutable_job_info_list(i)->set_is_running_tasks(is_running_tasks);
392+
reply->mutable_job_info_list(jj)->set_is_running_tasks(
393+
is_running_tasks);
393394
}
394395
size_t updated_finished_tasks = num_finished_tasks->fetch_add(1) + 1;
395396
try_send_reply(updated_finished_tasks);

src/ray/gcs/gcs_server/gcs_worker_manager.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ void GcsWorkerManager::HandleUpdateWorkerDebuggerPort(
268268
auto worker_data = std::make_shared<rpc::WorkerTableData>();
269269
worker_data->CopyFrom(*result);
270270
worker_data->set_debugger_port(debugger_port);
271-
Status status = gcs_table_storage_.WorkerTable().Put(
271+
Status put_status = gcs_table_storage_.WorkerTable().Put(
272272
worker_id, *worker_data, {on_worker_update_done, io_context_});
273-
if (!status.ok()) {
274-
GCS_RPC_SEND_REPLY(send_reply_callback, reply, status);
273+
if (!put_status.ok()) {
274+
GCS_RPC_SEND_REPLY(send_reply_callback, reply, put_status);
275275
}
276276
}
277277
};
@@ -325,10 +325,10 @@ void GcsWorkerManager::HandleUpdateWorkerNumPausedThreads(
325325
worker_data->has_num_paused_threads() ? worker_data->num_paused_threads() : 0;
326326
worker_data->set_num_paused_threads(current_num_paused_threads +
327327
num_paused_threads_delta);
328-
Status status = gcs_table_storage_.WorkerTable().Put(
328+
Status put_status = gcs_table_storage_.WorkerTable().Put(
329329
worker_id, *worker_data, {on_worker_update_done, io_context_});
330-
if (!status.ok()) {
331-
GCS_RPC_SEND_REPLY(send_reply_callback, reply, status);
330+
if (!put_status.ok()) {
331+
GCS_RPC_SEND_REPLY(send_reply_callback, reply, put_status);
332332
}
333333
}
334334
};

0 commit comments

Comments
 (0)