Skip to content
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

Merged
merged 5 commits into from Feb 28, 2018
Merged

Conversation

gaborznagy
Copy link
Collaborator

@gaborznagy gaborznagy commented Feb 15, 2018

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:

  • Who creates the DiskQueueOptions object and where is it passed to the QDisk object?
  • Is it okay to get a reference of the options member?

Probably fixes crash in #1770 (but not the corruption of the disk-queue).

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

Copy link
Collaborator

@furiel furiel left a 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.

disk_queue->restart_corrupted(disk_queue);

struct stat file_stat;
stat(filename, &file_stat);
Copy link
Collaborator

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.

@@ -965,6 +963,12 @@ qdisk_reset_file_if_possible(QDisk *self)
}
}

DiskQueueOptions *
qdisk_get_options_reference(QDisk *self)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

@MrAnno
Copy link
Collaborator

MrAnno commented Feb 22, 2018

Who creates the DiskQueueOptions object and where is it passed to the QDisk object?

DiskQueueOptions is owned by DiskQDestPlugin.
QDisk holds a reference that is passed via qdisk_init in the constructors of LogQueueDiskNonReliable and LogQueueDiskReliable.

Is it okay to get a reference of the options member?

I think it's OK. Otherwise, it wouldn't be easy to get the previous options instance in the middle of logqueue-disk.c.

LogQueue *q;
guint32 num;
guint32 single_msg_size;
} feed_and_assert_t;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. 👍

}
}
#undef TEST_DISK_BUF_SIZE
#undef TEST_MEM_SIZE
Copy link
Collaborator

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.

Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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.

{"test-diskq-restart.rqf", log_queue_disk_reliable_new, TRUE},
};

gint number_of_variants = sizeof(parameters)/sizeof(restart_test_parameters);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use gsize.

@kira-syslogng
Copy link
Contributor

Build FAILURE, the tests were executed on test branch: master and test suite: functions

@gaborznagy
Copy link
Collaborator Author

@kira-syslogng retest this please

@kira-syslogng
Copy link
Contributor

Build FAILURE, the tests were executed on test branch: master and test suite: functions

@gaborznagy
Copy link
Collaborator Author

@kira-syslogng retest this please

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@furiel
Copy link
Collaborator

furiel commented Feb 26, 2018

If style check is fixed, it is ready to merge.

Gabor Nagy added 5 commits February 26, 2018 12:28
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>
@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants