-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
MDEV-21166 Add Mroonga initialized check to Mroonga UDFs #3329
base: 10.5
Are you sure you want to change the base?
Conversation
Mroonga UDFs can't be used without loading Mroonga.
33e8e95
to
ed9fa5c
Compare
Is this check important for MariaDB? If so, the approach will be reasonable. |
@@ -296,6 +297,7 @@ static PSI_mutex_info mrn_mutexes[] = | |||
#endif | |||
|
|||
/* global variables */ | |||
bool mrn_initialized = false; |
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.
Continuing the comment in 3307:
Is this safe for multi-threading or CPU optimization? Is there a need to add mrn_mutexes similar to other global variables?
Yes. It's safe for multi-threading. This is changed only by st_mysql_plugin::init and st_mysql_plugin::deinit and they aren't called with multiple threads at once.
I'm not sure for CPU optimization. What situation do you think about?
I mean you probably need to ensure the memory barrier using mutex or atomic operations to maintain ordering constraints and avoid inconsistent memory views between threads due to CPU and compiler optimizations?
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.
There's a LOCK_plugin
around the initialization and de-initialization of all plugins and UDFs so there isn't actually a race condition here.
I'm still preferring the plugin_is_ready
enhancement to the server below to facilitate consistent checking of relations between plugins.
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.
@vuvova what you do you think about exposing the plugin_is_ready
function to plugins in include/mysql/services*.h
?
Sounds like a more consistent approach than global variables.
I think But generally at some point in the future — yes, it's needed for inter-plugin dependencies.Spider already uses it to check for Aria. |
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.
Approved based on my review of the previous PR and the comments in this one.
Description
If Mroonga UDFs such as
last_insert_id()
is used withoutINSTALL PLUGIN mroonga
, MariaDB is crashed. See MDEV-21166 for unexpected behavior details.Release Notes
I think that we don't need to add this to the release notes because this is unexpected usage. Mroonga UDFs are available only with
INSTALL PLUGIN mroonga
. This changes just add validations for unexpected usage.How can this PR be tested?
CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so'
withoutINSTALL PLUGIN mroonga
SELECT last_insert_grn_id();
ERROR 1123 (HY000): Can't initialize function 'last_insert_grn_id'; last_insert_grn_id(): Mroonga isn't initialized
) without crashWe can't add
.test
for this because we enable Mroonga for all tests understorage/mroonga/mysql-test/mroonga/storage/
:server/storage/mroonga/mysql-test/mroonga/storage/suite.opt
Line 1 in 3d4bdf7
Basing the PR against the correct MariaDB version
PR quality check