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
origvalue #3626
Comments
I fully agree that we need to rethink KEY_FLAG_SYNC. How can we proceed in that matter?
Yes, probably it was a mistake from the beginning to use origvalue for that. The values should be internal as they actually are specific to the plugins. |
I didn't suggest any changes to
The problem, was that the current solution needs the core to remove |
This was the initial purpose of KEY_FLAG_SYNC, too. Then renaming and metadata got added and now we found a situation where we again need the pure initial meaning. We could separate the 3 different sync flags, like we have for locking.
Good. 👍 |
Do we have an agreement to get rid of |
Yes, Also there is this example in the |
I mark this issue 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 the issue by writing a message here or create a new issue with the remainder of this issue. |
I agree that tooling might be interested in what the original value was. So maybe we should not make it internal and use We should even make a check in the contract that only one plugin writes a certain meta-value (it is okay if many read it). |
Yes, we definitely need a public "contract" to define how this kind of value conversion should be done. Ideally there would be library functions that handle everything except the actual conversion. But I'm not sure how feasible that is. Only The basic problem here is just that some "internal" values have multiple "external" representations and we need to remember which one was used. So we broadly need two things:
How this is best achieved, I don't know. Unless we find a simple solution, fixing this issue should probably be part of #4424, since it is kind of related to the whole specification system.
How would you check/enforce that? |
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. |
The current solution with
origvalue
metadata is far from ideal.The root cause of all the problems is that we wanted a solution that fulfils two properties:
kdbGet()
andkdbSet()
the value in the storage file should not change.kdb set /some/key myvalue
should put the exact stringmyvalue
into the storage file (assuming it is a valid value for the key).IMO a much better solution would be a flag similar to
KEY_FLAG_SYNC
that is set bykeySetRaw
(called bykeySetString
andkeySetBinary
) [1] and only cleared at the end ofkdbGet
(and maybekdbSet
). That way a storage plugin could reliably detect, when a key value was actively modified (even if the new value is the same as the old one).The second property would be solved automatically. The plugin would know that the key value is different than during
kdbGet()
and could skip any restore procedures and only do validation.The first property can be solved multiple ways. One solution is that plugins don't do anything during
kdbSet()
, if the flag is not set (i.e. key wasn't modified sincekdbGet()
). To restore the original value we would have general logic inkdbGet()
andkdbSet()
. The part inkdbGet()
copies the value received from the storage plugin into a meta key (e.g. reuseorigvalue
). InkdbSet()
we restore all unmodified keys to this backup before calling the storage plugin.Another (possibly more flexible) solution would be that plugins create
internal
meta keys to remember what representation [2] the value had before it was transformed inkdbGet()
. InkdbSet()
the plugin would reverse this transformation again.[1] Functions that modify the key value directly must set the flag as well. This includes
keyCopy
, but alsokeyVNew
. We need to set the flag on newly created keys, so that fully replacing a key also counts as modifying the value.[2] The advantage of storing the kind of representation instead of the exact value (e.g. storing
hex
instead of0xA3
) is that with very little extra work, the plugin could allow admins to define in aspec
what representation should be used in a storage file and always transform into that representation inkdbSet()
regardless of whether the key was modified. The disadvantage is that there might be ambiguous cases and values that cannot be restored exactly (e.g.0xaf
vs.0xaF
vs.0xAF
) without storing the exact value. But in the end that doesn't matter, since it is up to the plugin to define how values are restored and it is an implementation detail how that is accomplished.The text was updated successfully, but these errors were encountered: