dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

feat(server): implement TOUCH command

Open lsvmello opened this issue 2 years ago • 2 comments

Signed-off-by: Leonardo Mello [email protected]

Related issue https://github.com/dragonflydb/dragonfly/issues/409.

The difference between TOUCH and EXISTS on Redis is that TOUCH updates the last access time, I couldn't find such property on Dragonfly implementation, did I missed something?

Besides that the command are pretty much the same, so I didn't know if I should reuse or duplicate the functions, in the end since there are some logging there (and maybe for a future implementation) I chose to duplicate the function.

For the tests I saw that the OBJECT IDLETIME command is not implemented yet, so I didn't know what else I could do to test the scenario.

I must confess that I couldn't run the tests on my machine, I'm not a linux user so it might take some time for me to figure it out. Maybe you guys has faced this before? I'm using Ubuntu on WSL and this error comes up when I try to run the test:

leonardo@ubuntu:~/dragonfly/build-opt$ ./generic_family_test  
[==========] Running 17 tests from 1 test suite.  
[----------] Global test environment set-up.  
[----------] 17 tests from GenericFamilyTest 
[ RUN      ] GenericFamilyTest.Expire
F20221028 17:51:19.925204  1266 proactor.cc:391] Error initializing io_uring: (38) Function not implemented
*** Check failure stack trace: ***
F20221028 17:51:19.925315  1267 proactor.cc:391] Error initializing io_uring: (38) Function not implementedF20221028 17:51:19.925371  1268 proactor.cc:391] Error initializing io_uring: (38) Function not implemented
*** Check failure stack trace: ***
F20221028 17:51:19.925315  1267 proactor.cc:391] Error initializing io_uring: (38) Function not implementedF20221028 17:51:19.925371  1268 proactor.cc:391] Error initializing io_uring: (38) Function not implemented
*** Check failure stack trace: ***
    @     0x56552421a9d0  google::LogMessage::Fail()
    @     0x56552421a9d0  google::LogMessage::Fail()
    @     0x56552421a9d0  google::LogMessage::Fail()
    @     0x565524221bc3  google::LogMessage::SendToLog()
    @     0x565524221bc3  google::LogMessage::SendToLog()
    @     0x565524221bc3  google::LogMessage::SendToLog()
    @     0x56552421a387  google::LogMessage::Flush()
    @     0x56552421a387  google::LogMessage::Flush()
    @     0x56552421a387  google::LogMessage::Flush()
    @     0x56552421bd0f  google::LogMessageFatal::~LogMessageFatal()
    @     0x56552421bd0f  google::LogMessageFatal::~LogMessageFatal()
    @     0x56552421bd0f  google::LogMessageFatal::~LogMessageFatal()
    @     0x565524193228  util::uring::Proactor::Init()
    @     0x565524193228  util::uring::Proactor::Init()
    @     0x565524193228  util::uring::Proactor::Init()
    @     0x56552420bc3c  _ZNSt17_Function_handlerIFvvEZN4util12ProactorPool14SetupProactorsEvEUlvE_E9_M_invokeERKSt9_Any_data
    @     0x56552420bc3c  _ZNSt17_Function_handlerIFvvEZN4util12ProactorPool14SetupProactorsEvEUlvE_E9_M_invokeERKSt9_Any_data
    @     0x56552420bc3c  _ZNSt17_Function_handlerIFvvEZN4util12ProactorPool14SetupProactorsEvEUlvE_E9_M_invokeERKSt9_Any_data
    @     0x56552421762a  base::start_cpp_function()
    @     0x56552421762a  base::start_cpp_function()
    @     0x56552421762a  base::start_cpp_function()
    @     0x7f2106c50609  start_thread
    @     0x7f2106c50609  start_thread
    @     0x7f2106c50609  start_thread
    @     0x7f2106794133  clone
    @     0x7f2106794133  clone
    @     0x7f2106794133  clone
[failure_signal_handler.cc : 329] RAW: Signal 6 raised at PC=0x7f21066b800b while already in AbslFailureSignalHandler()
[failure_signal_handler.cc : 329] RAW: Signal 6 raised at PC=0x7f21066b800b while already in AbslFailureSignalHandler()
*** SIGABRT received at time=1666990279 on cpu 0 ***
PC: @     0x7f21066b800b  (unknown)  raise
Aborted

lsvmello avatar Oct 28 '22 21:10 lsvmello

It seems like your linux kernel on wsl has an old io_uring version that is not supported by dragonfly.

The test in the pipeline fails because you didn't add your new function to GenericFamily::Register.

Dragonfly doesn't support OBJECT IDELTIME currently and probably won't in the nearest future. Instead it reduces a keys likelihood of being evicted in the cache mode, which happends automatically on every lookup (and on exists). EXIST and TOUCH are the same now and most likely will be in the future... So in theory you could re-use all of exists functionality.

dranikpg avatar Oct 29 '22 15:10 dranikpg

Thanks @dranikpg, I'll try to update the kernel.

I've changed the commit to re-use the Exists logic.

lsvmello avatar Oct 31 '22 12:10 lsvmello

@romange lgtm

dranikpg avatar Oct 31 '22 19:10 dranikpg

Thanks, Leonardo!

romange avatar Oct 31 '22 19:10 romange