Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HFE to support AOF and replicas #13285

Merged

Conversation

moticless
Copy link
Collaborator

@moticless moticless commented May 21, 2024

  • For replica sake, rewrite commands H*EXPIRE* , HSETF, HGETF to have absolute unix time in msec.
  • On active-expiration of field, propagate HDEL to replica (propagateHashFieldDeletion())
  • On lazy-expiration, propagate HDEL to replica (hashTypeGetValue() now calls hashTypeDelete(). It also takes care to call propagateHashFieldDeletion()).
  • Fix H*EXPIRE* command such that if it gets flag LT and it doesn’t have any expiration on the field then it will considered as valid condition.

Note, replicas doesn’t make any active expiration, and should avoid lazy expiration. On hashTypeGetValue() it doesn't check expiration (As long as the master didn’t request to delete the field, it is valid)

TODO:

  • Attach dbid to HASH metadata. See here

@moticless moticless requested review from tezc, sundb and oranagra May 21, 2024 12:13
src/aof.c Outdated Show resolved Hide resolved
src/server.h Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Show resolved Hide resolved
@sundb
Copy link
Collaborator

sundb commented May 23, 2024

src/t_hash.c Outdated Show resolved Hide resolved
tests/unit/type/hash-field-expire.tcl Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
@moticless
Copy link
Collaborator Author

@moticless should the TODO in https://github.com/redis/redis/blob/a25b15392c3f50909ab2dafbcbdb3794ada29620/src/rdb.c#L2312:L2315 be handled here?

I will handle it on the next commit.

src/module.c Outdated Show resolved Hide resolved
src/module.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/aof.c Outdated Show resolved Hide resolved
src/t_hash.c Show resolved Hide resolved
src/aof.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/rdb.c Outdated Show resolved Hide resolved
src/rdb.c Outdated Show resolved Hide resolved
src/rdb.c Show resolved Hide resolved
src/rdb.c Outdated Show resolved Hide resolved
src/rdb.c Show resolved Hide resolved
src/aof.c Outdated Show resolved Hide resolved
/* Delete all the expired fields in one go */
if (r.expired > 0)
lpt->lp = lpDeleteRange(lpt->lp, 0, r.expired * 3);
ptr = lpNext(lpt->lp, ptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note to all of us, maybe we can implement this logic with lpFindCb() in future to avoid performance cost of lpNext() calls.

Comment on lines +5274 to +5277
int isHashDeleted;
int exists = hashTypeExists(key->db, key->value, field->ptr, &isHashDeleted);
/* hash-field-expiration is not exposed to modules */
serverAssert(isHashDeleted == 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i use hexpire command to create a hash with TTL fields, then operate the hash with RM_HashSet, will thia assertion be triggered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this matter, I am seeking input from those experienced with modules:

  • We likely need to pass the mode/flags of the opened key and respond appropriately.
  • Should we update the opened key if the key was deleted due to last field expiration?

@MeirShpilraien, perhaps you can assist. Thanks.

src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Show resolved Hide resolved
src/t_hash.c Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Outdated Show resolved Hide resolved
src/t_hash.c Show resolved Hide resolved
shared.hdel,
createStringObject((char*) key, sdslen(key)),
createStringObject(field, fieldLen)
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Later, maybe we can add a check to avoid creating these objects if we are not going to propagate anything.

@sundb sundb merged commit 33fc0fb into redis:hash-field-expiry-integ May 29, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants