khepri_adv, khepri_tx_adv: Always return khepri_adv:many_results()#303
Merged
Conversation
89e9807 to
c17382b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #303 +/- ##
==========================================
+ Coverage 89.66% 89.75% +0.08%
==========================================
Files 22 22
Lines 3251 3230 -21
==========================================
- Hits 2915 2899 -16
+ Misses 336 331 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
the-mikedavis
approved these changes
Oct 9, 2024
Collaborator
the-mikedavis
left a comment
There was a problem hiding this comment.
Just a minor typo I see in the second commit: "inser"=>"insert", otherwise I think this looks good 👍
c17382b to
f71656a
Compare
[Why] Functions such as `khepri_adv:get()` and `khepri_adv:put()` extracted the single node's properties from the query/command return value and returned only that. Therefore, the return value had a different form than other advanced functions' full node properties map. In a future patch, we want to add the nodes deleted by the "expiration" of `keep_while` conditions. They can be deleted after a delete or a put. If we want to achieve that, we need to make all functions return the same thing. [How] All functions that returned the single node props value are simplified to return the whole map, regardless of the number of tree nodes in the map.
[Why] The projection needs a tuple to insert it in ETS in the end. Therefore we can't use the `copy` method and store an atom. We need the projection function to create that tuple.
f71656a to
efc491c
Compare
Collaborator
Author
Thank you! It is fixed. |
dumbbell
added a commit
that referenced
this pull request
Mar 27, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] First, we introduce a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We then use the effective machine version passed in Ra metadata to `khepri_machine:apply()` to determine how to adapt the behaviour and return value. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
dumbbell
added a commit
that referenced
this pull request
Mar 28, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] We already introduced a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We use this API to determine how to adapt the behaviour and return value of puts and deletes. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
dumbbell
added a commit
that referenced
this pull request
Apr 1, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] We already introduced a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We use this API to determine how to adapt the behaviour and return value of puts and deletes. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
dumbbell
added a commit
that referenced
this pull request
Apr 1, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] We already introduced a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We use this API to determine how to adapt the behaviour and return value of puts and deletes. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
dumbbell
added a commit
that referenced
this pull request
Apr 1, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] We already introduced a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We use this API to determine how to adapt the behaviour and return value of puts and deletes. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
dumbbell
added a commit
that referenced
this pull request
Apr 1, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] We already introduced a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We use this API to determine how to adapt the behaviour and return value of puts and deletes. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
dumbbell
added a commit
that referenced
this pull request
Apr 2, 2025
…actions ... if the effective machine version is also old. [Why] A transaction function is extracted from the modules of a given Khepri member and is executed on all members. These members may run an older or a newer version of Khepri compared to the member that sent the transaction. Therefore, the transaction function and the Khepri public API must be aware of the effective machine version and adapt their behaviour to make sure that all state machine reaches the same state after applying a transaction. Without this, after the same transation function, an old and a new state machine may compute different state. This problem surfaced because #303 and #305 changed the return values of the advanced API: * all functions return a node props map, even those that operate on a single tree node. * all tree nodes indirectly deleted as a byproduct of another put or delete may be included in the returned node props map. This was ok with non-transaction functions because the return values are handled locally, regardless of the effective machine version. However, transactions were broken as explained in the previous paragraphs. [How] We already introduced a new public API, `khepri_tx:does_api_comply_with()` that returns a boolean to indicate if an old or new behaviour should be expected for a specific breaking change. We use this API to determine how to adapt the behaviour and return value of puts and deletes. For queries and read-only transactions, we will need to change how we call Ra because the regular query API doesn't provide the effective machine version. This will be part of a later commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Functions such as
khepri_adv:get()andkhepri_adv:put()extracted the single node's properties from the query/command return value and returned only that.Therefore, the return value had a different form than other advanced functions' full node properties map.
In a future patch, we want to add the nodes deleted by the "expiration" of
keep_whileconditions. They can be deleted after a delete or a put. If we want to achieve that, we need to make all functions return the same thing.How
All functions that returned the single node props value are simplified to return the whole map, regardless of the number of tree nodes in the map.