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
Document allows sequences of kdbGet & kdbSet #4520
Comments
Honestly I think this is a stupid idea. How would we disallow this? Just writing somewhere in the documentation that those sequences are disallowed won't help - programmers are lazy. We'd have to change the entire API so that all other sequences are disallowed by the compiler. If we can only do Also, such a behaviour isn't something that I'd expect from a piece of software that describes itself as a 'global key database'. Imagine if you'd have to reopen a new connection for every query and insert on a SQL database! As I see it, there are two options:
We can also automatically enable/disable the tracking based on whether any hook with the Implementation wise option 1 is easier, but option 2 will consume less memory with the copy-on-write approach. As this would work completely transparent for the users of the API, we could do both and evaluate which is better. Remember, measuring memory impact is part of my thesis, so this would give me something nice to compare 😉 |
I agree it's not a good solution, but this is C and the compiler and type system are limited. There already some preconditions you have to fulfil to call Also you have to keep in mind that libelektra/src/libs/elektra/kdb.c Lines 1164 to 1169 in 930673f
And this one libelektra/src/libs/elektra/kdb.c Lines 1617 to 1619 in 85da259
The both version could be a bit more clear what actually is allowed and needs to happen, but that's why we have this issue.
Of course you can do multiple kdbGet (handle, ksA, key);
kdbGet (handle, ksB, key);
kdbSet (handle, ksA, key); // OR kdbSet (handle, ksB, key);
// ---
kdbGet (handle, ks, keyA);
kdbGet (handle, ks, keyB);
kdbSet (handle, ks, keyA); // OR kdbSet (handle, ks, keyB);
// ---
kdbGet (handle, ksA, keyBelowKeyA);
kdbGet (handle, ksB, keyA);
kdbSet (handle, ksB, keyBelowKeyA); // OR kdbSet (handle, ksB, keyA);
AFAIK (but I'm no expert), it is generally not possible to have simultaneous independent SQL transactions on a single connection. Nested transactions can be possible, but not unrelated ones. In Elektra The difference is of course that (SQL being a Domain Specific Language) in SQL it is not just an error, but impossible to create code that does this. But like I said, here we are limited by what C can do.
Option 2 needs a lot more details to even be something we can consider.
There are (at least) three other option:
|
Yes. The complete tracking would take place within Then the altering methods (
|
That could need a lot of extra memory, even when the tracking is turned off. The flag could be kept in the existing Storing a callback function pointer in e.g. However, a big concern that can't really be addresses by any of these solution is: |
I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue. |
I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. |
Problem
From #4514:
If this is a valid sequence of events. Then neither
libelektra-kdb
nor anything else called by it (i.e. all plugins, including hook plugins) will be able to correctly calculate the added/changed/removed diff set at (C).Why? Simply put, because the
KDB
instancekdb
is used with two separateKeySet
s (a
&b
) andparentKey
s (keyA
&keyB
).The detailed reason is:
a
(EDIT: not the version that was passed in, but the one that will be returned bykdbGet
) somewhere (again doesn't matter whether this is done bykdbGet
or by a plugin)Solution
In #4514 we decided to simply disallow such problematic sequences. We now need to document precisely which sequences of
kdbGet
/kdbSet
calls we support.The text was updated successfully, but these errors were encountered: