DiceDB / dice

DiceDB is a redis-compliant, in-memory, real-time, and reactive database optimized for modern hardware and for building and scaling truly real-time applications.
https://dicedb.io/
Other
6.47k stars 1.02k forks source link

Inconsistent `APPEND`: APPEND command incorrectly resets TTL to -1 #1036

Open dankot12 opened 1 week ago

dankot12 commented 1 week ago

Description

In DiceDB, the APPEND command is currently resetting the TTL (Time to Live) of a key to -1 (no expiration) instead of preserving the existing TTL. This behavior is inconsistent with Redis, where the APPEND command does not affect the TTL of a key.

When a key with a set TTL is modified using APPEND, the TTL should continue counting down as expected, without being reset. However, in DiceDB, the TTL is being removed entirely, resulting in the key remaining indefinitely.

Impact

This issue may lead to unintended key persistence when using the APPEND command on keys that are expected to expire. It affects applications that rely on key expiration for cache management, session handling, or other use cases involving TTLs.

Steps to reproduce

Expected output

The expected output when the above set of commands (maybe when run on Redis)

127.0.0.1:7379> SET key "Hello" EX 20
OK
127.0.0.1:7379> APPEND key "World"
(integer) 10
127.0.0.1:7379> TTL key
(integer) 16

Observed output

The observed output when the above set of commands when run on DiceDB

127.0.0.1:7379> SET key "Hello" EX 20
OK
127.0.0.1:7379> APPEND key "World"
(integer) 10
127.0.0.1:7379> TTL key
(integer) -1   # TTL is incorrectly reset to -1 (no expiration)

Expectations for resolution

This issue will be considered resolved when the following things are done

  1. Changes in the dice code to meet the expected behavior where the TTL is preserved after the APPEND operation.
  2. Addition of relevant test case to ensure we catch the regression

You can find the tests under the integration_tests directory of the dice repository and the steps to run are in the README file. Refer to the following links to set up DiceDB and Redis 7.2.5 locally

dankot12 commented 1 week ago

Hi @lucifercr07 @arpitbbhayani, will you please asign this issue to me?