Libelektra: Possible bug in kdbGet

Created on 14 Mar 2019  路  7Comments  路  Source: ElektraInitiative/libelektra

@markus2330 I think there might be a bug in kdbGet related to global plugins:

https://github.com/ElektraInitiative/libelektra/blob/9010360ba57231dfd05a378fd2b67c324671dde1/src/libs/elektra/kdb.c#L874-L905

https://github.com/ElektraInitiative/libelektra/blob/9010360ba57231dfd05a378fd2b67c324671dde1/src/libs/elektra/kdb.c#L510-L542

As you can see, elektraGetDoUpdate is called with parentKey, which is then modified by this function. Later on elektraGlobalGet is called with this parentKey. But if I understand correctly how global plugins should work, the key name should be reset to initalParent beforehand not afterwards (line 903).

Most helpful comment

I was looking into it because of the options plugin. As discussed, ideally we would add a placement procgetstorage between getstorage and postgetstorage which would be used for plugins that write to the proc namespace.

This is also relevant for caching, because those plugin would always have to be executed (if kdbGet is called twice in the same process, we could skip some plugins, e.g. the options plugin).

The options plugin has to know the parent key of the current applications specification. Normally this is the parent key passed to kdbGet. This is why I was looking at what parent key is passed to global plugins, because normal plugins obviously get the parent of their mountpoint not what is passed to kdbGet.

All 7 comments

Thank you for reporting this problem!

@mpranj Is this something you will change within your PR?

This has not changed within my current cache PR.

The global plugins are not fully implemented, so there are definitely even more bugs. To my knowledge the parentKey should not even be initialParent, but actually the name should contain the global position. That way, the global plugins would know where they are currently called from.

@mpranj Thank you for looking into it. We are already waiting for your implementation of the global plugins :+1:

@kodebach do you have a concrete situation where this creates a problem? Is a fix urgent?

I was looking into it because of the options plugin. As discussed, ideally we would add a placement procgetstorage between getstorage and postgetstorage which would be used for plugins that write to the proc namespace.

This is also relevant for caching, because those plugin would always have to be executed (if kdbGet is called twice in the same process, we could skip some plugins, e.g. the options plugin).

The options plugin has to know the parent key of the current applications specification. Normally this is the parent key passed to kdbGet. This is why I was looking at what parent key is passed to global plugins, because normal plugins obviously get the parent of their mountpoint not what is passed to kdbGet.

Considering the current state of the implementation I am absolutely open to suggestions.

I think it might even make sense to put more information in the parentKey for global plugins. We can keep the initialParent as parentKey and add the position and other information as meta-keys.

Another option is to exchange additional information via the global keyset.

@kodebach I think you resolved this problem by implementing the PROCGETSTORAGE position. Can we close this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanssecours picture sanssecours  路  57Comments

KurtMi picture KurtMi  路  85Comments

markus2330 picture markus2330  路  62Comments

ingwinlu picture ingwinlu  路  35Comments

markus2330 picture markus2330  路  49Comments