Skip to content

Commit

Permalink
fix spill bug (#17187)
Browse files Browse the repository at this point in the history
(cherry picked from commit b26fcd3)
  • Loading branch information
scv119 authored and jiaodong committed Jul 21, 2021
1 parent b142368 commit c2d70bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/ray/object_manager/spilled_object_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,18 @@ SpilledObjectReader::SpilledObjectReader(std::string file_path, uint64_t object_
}
file_path = match_groups[1].str();
try {
object_offset = std::stoi(match_groups[2].str());
object_size = std::stoi(match_groups[3].str());
auto offset = std::stoll(match_groups[2].str());
auto size = std::stoll(match_groups[3].str());
if (offset < 0 || size < 0) {
RAY_LOG(ERROR) << "Offset and size can't be negative. offset: " << offset
<< ", size: " << size;
return false;
}
object_offset = offset;
object_size = size;
} catch (...) {
RAY_LOG(ERROR) << "Failed to parse offset: " << match_groups[2].str()
<< " and size: " << match_groups[3].str();
return false;
}
return true;
Expand Down
13 changes: 12 additions & 1 deletion src/ray/object_manager/test/spilled_object_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ TEST(SpilledObjectReaderTest, ParseObjectURL) {
"file:///C:/Users/file.txt", 123, 456);
assert_parse_success("/tmp/file.txt?offset=123&size=456", "/tmp/file.txt", 123, 456);
assert_parse_success("C:\\file.txt?offset=123&size=456", "C:\\file.txt", 123, 456);

assert_parse_success(
"/tmp/ray/session_2021-07-19_09-50-58_115365_119/ray_spillled_objects/"
"2f81e7cfcc578f4effffffffffffffffffffffff0200000001000000-multi-1?offset=0&size="
"2199437144",
"/tmp/ray/session_2021-07-19_09-50-58_115365_119/ray_spillled_objects/"
"2f81e7cfcc578f4effffffffffffffffffffffff0200000001000000-multi-1",
0, 2199437144);
assert_parse_success("/tmp/123?offset=0&size=9223372036854775807", "/tmp/123", 0,
9223372036854775807);

assert_parse_fail("/tmp/123?offset=-1&size=1");
assert_parse_fail("/tmp/123?offset=0&size=9223372036854775808");
assert_parse_fail("file://path/to/file?offset=a&size=456");
assert_parse_fail("file://path/to/file?offset=0&size=bb");
assert_parse_fail("file://path/to/file?offset=123");
Expand Down

0 comments on commit c2d70bd

Please sign in to comment.