Fix crash in active defrag (#883)

This crash would happen if we disable active defrag while it is running,
then re-enable active defrag. In this case the `expires_cursor` variable
in `activeDefragCycle()` would not be reset to 0 when disabling active
defrag, so when re-enabling it, this variable can still be non-zero,
which causes the `db` and other variables to not be initialized before
starting the defrag process.

Signed-off-by: Pierre Turin <pieturin@amazon.com>
This commit is contained in:
Pierre 2024-08-12 13:38:20 -07:00 committed by GitHub
parent 579cca5f00
commit 68d887636e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -941,6 +941,7 @@ void activeDefragCycle(void) {
defrag_later_cursor = 0; defrag_later_cursor = 0;
current_db = -1; current_db = -1;
cursor = 0; cursor = 0;
expires_cursor = 0;
db = NULL; db = NULL;
goto update_metrics; goto update_metrics;
} }