mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-12 02:45:45 +02:00
feat: Allow pre-declaring Lua SHAs to run with undeclared keys (#3465)
* feat: Allow pre-declaring Lua SHAs to run with undeclared keys By using `--lua_undeclared_keys_shas=SHA,SHA,SHA` users can now specify which scripts should run globally (undeclared keys) without explicit support from the scripts themselves. Fixes #2442
This commit is contained in:
parent
1b1a83dc58
commit
aa424c81af
3 changed files with 47 additions and 0 deletions
|
@ -38,6 +38,15 @@ ABSL_FLAG(bool, lua_allow_undeclared_auto_correct, false,
|
|||
"access undeclared keys, automaticaly set the script flag to be able to run with "
|
||||
"undeclared key.");
|
||||
|
||||
ABSL_FLAG(
|
||||
std::vector<std::string>, lua_undeclared_keys_shas,
|
||||
std::vector<std::string>({
|
||||
"351130589c64523cb98978dc32c64173a31244f3", // Sidekiq, see #2442
|
||||
"6ae15ef4678593dc61f991c9953722d67d822776", // Sidekiq, see #2442
|
||||
}),
|
||||
"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.");
|
||||
|
||||
namespace dfly {
|
||||
using namespace std;
|
||||
using namespace facade;
|
||||
|
@ -262,6 +271,11 @@ io::Result<string, GenericError> ScriptMgr::Insert(string_view body, Interpreter
|
|||
return params_opt.get_unexpected();
|
||||
auto params = params_opt->value_or(default_params_);
|
||||
|
||||
auto undeclared_shas = absl::GetFlag(FLAGS_lua_undeclared_keys_shas);
|
||||
if (find(undeclared_shas.begin(), undeclared_shas.end(), sha) != undeclared_shas.end()) {
|
||||
params.undeclared_keys = true;
|
||||
}
|
||||
|
||||
// If the script is atomic, check for possible squashing optimizations.
|
||||
// For non atomic modes, squashing increases the time locks are held, which
|
||||
// can decrease throughput with frequently accessed keys.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue