Skip to content

Commit

Permalink
fix: several bugs (#4500)
Browse files Browse the repository at this point in the history
1. Fixes #4466 (we did not check validity of the scan cursor)
   We fix it by quietly returning "end of scan" result, i.e. no error are returned.
2. Add 34b1048274c8e50a0cc587a3ed9c383a82bb78c5 sha to the lua_undeclared_keys_shas list.
3. Pull helio that fixes bugs with WaitQueue and IdleTasks: romange/helio@2ab4412
  • Loading branch information
romange authored Jan 24, 2025
1 parent 69ef997 commit 23af41c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helio
7 changes: 4 additions & 3 deletions src/core/dash.h
Original file line number Diff line number Diff line change
Expand Up @@ -954,12 +954,13 @@ auto DashTable<_Key, _Value, Policy>::GetRandomCursor(absl::BitGen* bitgen) -> C
template <typename _Key, typename _Value, typename Policy>
template <typename Cb>
auto DashTable<_Key, _Value, Policy>::Traverse(Cursor curs, Cb&& cb) -> Cursor {
if (curs.bucket_id() >= Policy::kBucketNum) // sanity.
return 0;

uint32_t sid = curs.segment_id(global_depth_);
uint8_t bid = curs.bucket_id();

// Test validity of the cursor.
if (bid >= Policy::kBucketNum || sid >= segment_.size())
return 0;

auto hash_fun = [this](const auto& k) { return policy_.HashFn(k); };

bool fetched = false;
Expand Down
5 changes: 5 additions & 0 deletions src/server/generic_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -872,4 +872,9 @@ TEST_F(GenericFamilyTest, RestoreOOM) {
EXPECT_THAT(resp, ErrArg("Out of memory"));
}

TEST_F(GenericFamilyTest, Bug4466) {
auto resp = Run({"SCAN","9223372036854775808"}); // an invalid cursor should not crash us.
EXPECT_THAT(resp, RespElementsAre("0", RespElementsAre()));
}

} // namespace dfly
1 change: 1 addition & 0 deletions src/server/script_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ABSL_FLAG(
std::vector<std::string>({
"351130589c64523cb98978dc32c64173a31244f3", // Sidekiq, see #2442
"6ae15ef4678593dc61f991c9953722d67d822776", // Sidekiq, see #2442
"34b1048274c8e50a0cc587a3ed9c383a82bb78c5" // Sidekiq
}),
"Comma-separated list of Lua script SHAs which are allowed to access undeclared keys. SHAs are "
"only looked at when loading the script, and new values do not affect already-loaded script.");
Expand Down

0 comments on commit 23af41c

Please sign in to comment.