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
Diskq: fix restart disk-queue #1886
Conversation
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
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.
Looks good to me. Two minor comments.
modules/diskq/tests/test_diskq.c
Outdated
disk_queue->restart_corrupted(disk_queue); | ||
|
||
struct stat file_stat; | ||
stat(filename, &file_stat); |
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 you assert for the return value? It would support the Enable warnings PR.
modules/diskq/qdisk.c
Outdated
@@ -965,6 +963,12 @@ qdisk_reset_file_if_possible(QDisk *self) | |||
} | |||
} | |||
|
|||
DiskQueueOptions * | |||
qdisk_get_options_reference(QDisk *self) |
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.
From the name I would expect DiskQueueOptions is refcounted and this function increases the reference before returning. I suggest just calling qdisk_get_options.
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 had problem naming this function. 😄
I am ok with qdisk_get_options
.
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.
+1 for qdisk_get_options
.
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.
Okay, after our discussion I agree.
I think it's OK. Otherwise, it wouldn't be easy to get the previous options instance in the middle of |
LogQueue *q; | ||
guint32 num; | ||
guint32 single_msg_size; | ||
} feed_and_assert_t; |
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.
Nice. 👍
modules/diskq/tests/test_diskq.c
Outdated
} | ||
} | ||
#undef TEST_DISK_BUF_SIZE | ||
#undef TEST_MEM_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 wouldn't unset these macros.
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 simple use a const
variable ?
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.
TEST_MEM_SIZE
is not even used for assertion as checking disk_buf_size
is good enough.
I prefer macros as constants, but for here the const var is good too.
I have changed it to const var. and moved it inside the function.
modules/diskq/tests/test_diskq.c
Outdated
{"test-diskq-restart.rqf", log_queue_disk_reliable_new, TRUE}, | ||
}; | ||
|
||
gint number_of_variants = sizeof(parameters)/sizeof(restart_test_parameters); |
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 use gsize
.
2275bf7
to
e5ff74e
Compare
Build FAILURE, the tests were executed on test branch: master and test suite: functions |
@kira-syslogng retest this please |
Build FAILURE, the tests were executed on test branch: master and test suite: functions |
@kira-syslogng retest this please |
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
If style check is fixed, it is ready to merge. |
Signed-off-by: Gabor Nagy <gabor.nagy@balabit.com>
As QDisk objects can be reused if a LogQueueDisk child-class creates a new disk-queue file (known as restart), QDisk object should be properly initialized before the QDisk object would be first used (in qdisk_start. i.e. init_instance functionality is missing. For this the `file_size` member is initialized in qdisk_init and qdisk_start. Signed-off-by: Gabor Nagy <gabor.nagy@balabit.com>
In restart_diskq QDisk object is reused without re-initialization. Signed-off-by: Gabor Nagy <gabor.nagy@balabit.com>
Signed-off-by: Gabor Nagy <gabor.nagy@balabit.com>
Signed-off-by: Gabor Nagy <gabor.nagy@balabit.com>
e5ff74e
to
e4446ec
Compare
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
If a pop operation fails during reading from the disk-queue file the restart_corrupted method is called.
It has to close the current disk-queue file and rename it to ".corrupted" then it has to start a new file from scratch.
The function reuses the existing QDisk object after a deinit call, although it forgets to initialize the object properly before use and that causes a crash.
Questions:
options
member?Probably fixes crash in #1770 (but not the corruption of the disk-queue).