-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor(server): Privatize PreUpdate()
and PostUpdate()
#2322
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
Conversation
While at it: * Make `PreUpdate()` not decrease object size * Remove redundant leftover call to `PreUpdate()` outside `DbSlice`
As this is the last PR for this change I think its worth adding a test for the memory accounting |
Unfortunately it seems like it's not trivial to directly compare memory counters, as some values are slightly different after save/load:
(note the scroll to the right - these are long lines) I'll continue looking into this next week though |
The best solution I can think of (which will keep tests robust and not flaky) is just to make sure that all of these counters are |
I also thought about asserting that the values are at least 50% of the original values, I'm not sure if we'll have a failure very once in a while because of that though. wdyt? |
checking that the values are at least %50 after reload sounds good. |
That's a great idea! Done. |
tests/dragonfly/snapshot_test.py
Outdated
for counter, value in memory_before.items(): | ||
assert memory_after[counter] >= 0.5 * value | ||
|
||
# Delete all keys from all DBs |
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.
Oh I think we do this logic of delete and check not after we load from snapshot, because this way we dont check all the update commands accounting correctly
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.
That's an even better idea!
(I added that on top of what I already had)
@@ -270,6 +311,13 @@ async def test_snapshot(self, df_seeder_factory, df_server): | |||
await a_client.connection_pool.disconnect() | |||
|
|||
assert await seeder.compare(start_capture, port=df_server.port) | |||
memory_after = await self._get_info_memory_fields(a_client) | |||
for counter, value in memory_before.items(): | |||
assert memory_after[counter] >= 0.5 * value |
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 add a comment why we check > 0.5 *
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.
done
await self._delete_all_keys(a_client) | ||
memory_counters = await self._get_info_memory_fields(a_client) | ||
assert memory_counters == {"object_used_memory": 0} | ||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.slow | ||
async def test_snapshot(self, df_seeder_factory, df_server): |
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.
add a comment what we check in this tests
- check that after reloading the snapshot file the data is the same
- check memory counting after loading from snapshot is similar to before creating a snapshot
- check memory counting after deleting all keys loaded by snapshot - this validates the memory counting when loading from snapshot
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.
Done
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 you did not push this commit as I dont see this changes?
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.
oops, sorry!
While at it:
PreUpdate()
not decrease object sizePreUpdate()
outsideDbSlice