Repository navigation
impl: KVS Instance state registry [cpp] - #538
karolnowak wants to merge 1 commit into
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
3168f21 to
f6be05e
Compare
|
Documentation preview for this pull request is available at: |
f6be05e to
cc7e450
Compare
| KvsStateRegistry(KvsStateRegistry&&) = delete; | ||
|
|
||
| KvsStateRegistry& operator=(const KvsStateRegistry&) = delete; | ||
| KvsStateRegistry& operator=(KvsStateRegistry&&) = delete; |
There was a problem hiding this comment.
please let us try to discuss this approach coming meeting .
based on discussion we can decide if we will proceed with this approach or another approach.
arkjedrz
left a comment
There was a problem hiding this comment.
Review is probably not exhaustive, but discussions might be needed at this points.
| /* Create Test Data*/ | ||
| kvs_b.kvs_.insert({"test_kvs", KvsValue(42.0)}); | ||
| kvs_b.default_values_.insert({"test_default", KvsValue(true)}); | ||
| kvs_b.state_->current_values_.insert({"test_kvs", KvsValue(42.0)}); |
There was a problem hiding this comment.
Not in scope here, but this could be avoided with #574
cc7e450 to
e734e41
Compare
e734e41 to
614a402
Compare
614a402 to
62b64f8
Compare
62b64f8 to
e30a0d8
Compare
e30a0d8 to
4ee69cc
Compare
A registry to share the same state of a given KVS Instance. It avoids loading a given KVS Instance from disk again which could otherwise lead to the use of different versions of the same instance. Signed-off-by: Karol Nowak <Karol.Novak.Ext@qorix.ai>
4ee69cc to
ed50e69
Compare
|
|
||
| namespace score::mw::per::kvs | ||
| { | ||
| /// @brief Forward declaration. |
| const std::string directory = directory_.empty() ? std::string{"./"} : directory_; | ||
| const std::string directory{directory_.empty() ? std::string{"./"} : directory_}; | ||
|
|
||
| const std::size_t max_snapshots_clmaped{std::clamp(max_snapshots_, 0ul, KVS_MAX_SNAPSHOTS_UPPER_BOUND)}; |
| { | ||
| /// Protects access to the shared state. | ||
| std::mutex mutex; | ||
| /// Instance id that has been specified during creation. |
There was a problem hiding this comment.
Nitpick - ID instead of id.
| class KvsInstanceState; | ||
|
|
||
| /// @brief Maximum number or instances. | ||
| constexpr std::size_t KVS_MAX_INSTANCE_COUNT{8ul}; |
There was a problem hiding this comment.
Nitpick - align with Rust to 10.
IMO this doesn't matter much, since other storage type should be used.
| class KvsInstanceState; | ||
|
|
||
| /// @brief Maximum number or instances. | ||
| constexpr std::size_t KVS_MAX_INSTANCE_COUNT{8ul}; |
There was a problem hiding this comment.
Shouldn't that be a kvsbuilder.hpp constant?
| std::mutex mutex{}; | ||
| /// Array. | ||
| Array array{}; | ||
| /// Entry count. |
There was a problem hiding this comment.
Drop the size, map instance ID directly to the array.
E.g., if requested KVS for instance ID == 3, then occupy this slot. If requested KVS for instance ID then report error that it cannot be made.
Problem
The existing [cpp] impl allows to load the same instance from disk many times.
After loading, each KVS operates on its own non-shared entries.
This can affect data integrity when two KVSs, which refer to the same instance, save their entries on disk.
Solution
A registry to share the same state of a given KVS Instance.
Note
At the moment, the registry implements the Singleton pattern and is hidden from the lib user.
I believe that the registry should be rewritten so that: