mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix: enforce load limits when loading snapshot (#4136)
* fix: enforce load limits when loading snapshot Prevent loading snapshots with used memory higher than max memory limit. 1. Store the used memory metadata only inside the summary file 2. Load the summary file before loading anything else, and if the used-memory is higher, abort the load. --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
4e7800f94f
commit
0e7ae34fe4
9 changed files with 82 additions and 81 deletions
|
@ -94,7 +94,7 @@ TEST_F(RdbTest, Crc) {
|
|||
|
||||
TEST_F(RdbTest, LoadEmpty) {
|
||||
auto ec = LoadRdb("empty.rdb");
|
||||
CHECK(!ec);
|
||||
ASSERT_FALSE(ec) << ec;
|
||||
}
|
||||
|
||||
TEST_F(RdbTest, LoadSmall6) {
|
||||
|
@ -646,4 +646,13 @@ TEST_F(RdbTest, LoadHugeStream) {
|
|||
ASSERT_EQ(2000, CheckedInt({"xlen", "test:0"}));
|
||||
}
|
||||
|
||||
TEST_F(RdbTest, SnapshotTooBig) {
|
||||
// Run({"debug", "populate", "10000", "foo", "1000"});
|
||||
// usleep(5000); // let the stats to sync
|
||||
max_memory_limit = 100000;
|
||||
used_mem_current = 1000000;
|
||||
auto resp = Run({"debug", "reload"});
|
||||
ASSERT_THAT(resp, ErrArg("Out of memory"));
|
||||
}
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue