-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Right now the expirationd worker start can be delayed until the space it is supposed to scan is created
However, there is no such mechanism for the is_expired
function.
Consider this scenario:
cartridge-extensions
is used- we want to inject the function we would use as the
is_expired
function through cartridge-extensions
- supply a function to be used as the
is_expired
function - configure
expiratoind
to use this function
Like this (in clusterwide config):
extensions/expiration.lua
local M = {}
local fiber = require('fiber')
function M.check_ttl(args, tuple)
local now = fiber.time()
local ttl = tuple[args.ttl_field]
local timestamp = tuple[args.timestamp_field]
if (ttl == nil or timestamp == nil) then
return false
end
return now > timestamp + ttl
end
return M
extensions/config.yml
functions:
check_ttl:
module: extensions.expiration
handler: check_ttl
events:
- binary:
path: __check_ttl
expirationd.yml
# tasks
expire_session:
space: session
is_expired: __check_ttl
options:
args:
ttl_field: max_inactive_interval
timestamp_field: last_accessed_time
is_master_only: true
This scenario would work until a restart of one instance occurs. After the restart, an error as this would occur:
text
myapp.s2-1 | 2023-03-10 16:36:10.086 [32983] main/103/init.lua confapplier.lua:156 E> Instance entering failed state: ConfigFound -> InitError
myapp.s2-1 | ValidateConfigError: ...p/.rocks/share/tarantool/cartridge/roles/expirationd.lua:188: ...p/.rocks/share/tarantool/cartridge/roles/expirationd.lua:130: expirationd: is_expired must be a function name in _G
myapp.s2-1 | stack traceback:
myapp.s2-1 | ...p/.rocks/share/tarantool/cartridge/roles/expirationd.lua:188: in function <...p/.rocks/share/tarantool/cartridge/roles/expirationd.lua:171>
myapp.s2-1 | [C]: in function 'xpcall'
myapp.s2-1 | ...ring_session_tnt/myapp/.rocks/share/tarantool/errors.lua:145: in function 'pcall'
myapp.s2-1 | ...ion_tnt/myapp/.rocks/share/tarantool/cartridge/roles.lua:377: in function 'validate_config'
myapp.s2-1 | ...t/myapp/.rocks/share/tarantool/cartridge/confapplier.lua:863: in function 'init'
myapp.s2-1 | ...g_session_tnt/myapp/.rocks/share/tarantool/cartridge.lua:858: in function 'cfg'
myapp.s2-1 | /home/bass/LocalCode/spring_session_tnt/myapp/init.lua:36: in main chunk
The error is unfixable via configuration re-application, as you can't apply config in a cluster that is in error state.
As a solution, I think that this could be done:
- relax the requirement on the
is_tuple_expired
argument so as to not require for the specified function to exist when theexpirationd.start
is called
Mons
Metadata
Metadata
Assignees
Labels
No labels