-
Notifications
You must be signed in to change notification settings - Fork 998
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
feat(server): use listpack node encoding for list #3914
Conversation
@@ -439,7 +444,8 @@ error_code RdbSerializer::SaveListObject(const PrimeValue& pv) { | |||
DVLOG(3) << "QL node (encoding/container/sz): " << node->encoding << "/" << node->container | |||
<< "/" << node->sz; | |||
|
|||
if (QL_NODE_IS_PLAIN(node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I still need to fix the way we serialize plane node when list_rdb_encode_v2=false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked to @chakaz about this and suggested to create an appropriate dump by redis 6 and add it to our rdb_test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adiholden asked me to look into adding a full redis 7 replication test, in addition to our existing redis 6 one
that should be a superset (well, almost) of what you asked for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have replication tests with redis server which include list type, this is checking the rdb load logic in dfly
we can add there big values if needed
have not checked the code but It is important that we still be able to load redis-6 rdb files and old DF snapshots with ziplist encoding unrelated to the flag. |
@@ -439,7 +444,8 @@ error_code RdbSerializer::SaveListObject(const PrimeValue& pv) { | |||
DVLOG(3) << "QL node (encoding/container/sz): " << node->encoding << "/" << node->container | |||
<< "/" << node->sz; | |||
|
|||
if (QL_NODE_IS_PLAIN(node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adiholden asked me to look into adding a full redis 7 replication test, in addition to our existing redis 6 one
that should be a superset (well, almost) of what you asked for
src/server/rdb_save.cc
Outdated
@@ -49,6 +49,7 @@ ABSL_FLAG(dfly::CompressionMode, compression_mode, dfly::CompressionMode::MULTI_ | |||
"set 2 for multi entry zstd compression on df snapshot and single entry on rdb snapshot," | |||
"set 3 for multi entry lz4 compression on df snapshot and single entry on rdb snapshot"); | |||
ABSL_FLAG(int, compression_level, 2, "The compression level to use on zstd/lz4 compression"); | |||
ABSL_FLAG(bool, list_rdb_encode_v2, true, "Use v2 rdb encoding of list object"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we run the list unit tests once with this true and once with false?
also, didn't you say you wanted the default to be false
for this? (I could have misunderstood you, it's find to be true if you want it to be such)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also^2: I thought you wanted this flag to be toggleable at runtime (i.e. via CONFIG
), is it not the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we need to toggle it - our cloud service does not require redis-6 RDB compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see config_registry.RegisterMutable in server_family you can set the flag in runtime
I wanted the defualt to be true, I dont see a reason to convert listpack to ziplist encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to run the unit test with flag false I need need first to fix the issue with encoding of big list entry with the ziplist encoding
tests/dragonfly/snapshot_test.py
Outdated
**BASIC_ARGS, | ||
"proactor_threads": 4, | ||
"dbfilename": "test-redis-load-rdb", | ||
"list_rdb_encode_v2": "false", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"list_rdb_encode_v2": "false", | |
"list_rdb_encode_v2": "false", # Needed for compatibility with Redis 6 |
This is indeed what @adiholden did 🤓 |
@romange This PR only changes the default way we encode lists |
Please verify that RDB files that are created by DF with large list entries can be loaded by Redis 7 when this flag is on. |
Shahar run the test_redis_load_snapshot with redis 7 and with the flag list_rdb_encode_v2 set to true and the test passed. |
if (container == QUICKLIST_NODE_CONTAINER_PLAIN) { | ||
quicklistAppendPlainNode(ql, (uint8_t*)sv.data(), sv.size()); | ||
lp = (uint8_t*)zmalloc(sv.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Roman is implying that this is a nasty bug :)
src/server/rdb_save.cc
Outdated
@@ -49,6 +49,7 @@ ABSL_FLAG(dfly::CompressionMode, compression_mode, dfly::CompressionMode::MULTI_ | |||
"set 2 for multi entry zstd compression on df snapshot and single entry on rdb snapshot," | |||
"set 3 for multi entry lz4 compression on df snapshot and single entry on rdb snapshot"); | |||
ABSL_FLAG(int, compression_level, 2, "The compression level to use on zstd/lz4 compression"); | |||
ABSL_FLAG(bool, list_rdb_encode_v2, true, "Use v2 rdb encoding of list object"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please improve help string of the flag. whats is v2 rdb encoding? when the flag is true what we are compatible with?
@@ -861,6 +861,7 @@ void ServerFamily::Init(util::AcceptServer* acceptor, std::vector<facade::Listen | |||
config_registry.RegisterMutable("tls_ca_cert_dir"); | |||
config_registry.RegisterMutable("replica_priority"); | |||
config_registry.RegisterMutable("lua_undeclared_keys_shas"); | |||
config_registry.RegisterMutable("list_rdb_encode_v2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need, imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have any prod issues with the new impl we will be able to recover
@@ -150,7 +150,14 @@ async def test_dbfilenames( | |||
|
|||
|
|||
@pytest.mark.asyncio | |||
@dfly_args({**BASIC_ARGS, "proactor_threads": 4, "dbfilename": "test-redis-load-rdb"}) | |||
@dfly_args( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not in rdb_test.cc ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a python test that checks that redis can load dragonfly snapshot. what do you want to put in rdb_test.cc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
ABSL_DECLARE_FLAG(bool, list_rdb_encode_v2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer, you could also use SetTestFlag("list_rdb_encode_v2", "false");
and not declare this flag
if doesn't really matter in any way, so your call
if (container == QUICKLIST_NODE_CONTAINER_PLAIN) { | ||
quicklistAppendPlainNode(ql, (uint8_t*)sv.data(), sv.size()); | ||
lp = (uint8_t*)zmalloc(sv.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Roman is implying that this is a nasty bug :)
Signed-off-by: adi_holden <[email protected]>
Signed-off-by: adi_holden <[email protected]>
Signed-off-by: adi_holden <[email protected]>
Signed-off-by: adi_holden <[email protected]>
Signed-off-by: adi_holden <[email protected]>
Signed-off-by: adi_holden <[email protected]>
29d8430
to
644cb14
Compare
Until now encoding of list was using ziplist encoding, which is supported by redis 6
This PR introduces encoding of list using listpack encoding by default (supported by redis 7), optionally change the encoding to ziplist encoding using flag.
This PR also fixes a bug: when serializing big entry of list it was serialized as plain node using lispack encoding therefore when loading the rdb we got error. By moving encoding all the list nodes to listpack encoding we fix this bug.