-
Notifications
You must be signed in to change notification settings - Fork 26
feat(keystore) Define Branch Key Store read consistency semantics #302
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
Open
brandondahler
wants to merge
3
commits into
awslabs:master
Choose a base branch
from
brandondahler:features/ReadConsistencySemantics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
...ges/2025-07-24_define-branch-key-store-read-consistency-semantics/background.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
[//]: # "Copyright Amazon.com Inc. or its affiliates. All Rights Reserved." | ||
[//]: # "SPDX-License-Identifier: CC-BY-SA-4.0" | ||
|
||
# Define Branch Key Store read consistency semantics | ||
|
||
# Definitions | ||
|
||
## Conventions used in this document | ||
|
||
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", | ||
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be | ||
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119). | ||
|
||
# Background | ||
|
||
The [branch key store](../../framework/branch-key-store.md) persists branch key versions | ||
in a persistent data store such as a DynamoDb table. | ||
|
||
These distributed data stores often offer configurable read consistency, | ||
allowing customers to choose eventually consistent reads | ||
for optimal cost and performance | ||
if stale results are acceptable for their use-case. | ||
|
||
The current specification does not specify when agents should expect | ||
the results of the read operations to reflect the updated state caused by mutation operations. | ||
|
||
The current implementation utilizes eventually consistent reads in all current usage. | ||
|
||
Consequently, a read operation will not necessarily reflect the latest results | ||
of a mutation operation | ||
even if performed by the same agent in a serialized manner. | ||
|
||
This change adds the option to require consistent reads and | ||
clarifies the required consistent read behavior for read operations. | ||
|
||
## Detailed Explanation | ||
|
||
The Branch Key Store's `GetActiveBranchKey`, `GetBranchKeyVersion`, and `GetBeaconKey` operations | ||
utilize AWS DDB `GetItem` calls which | ||
do not set the `ConsistentRead` flag. | ||
|
||
When the `ConsistentRead` flag is unset or `false`, | ||
DynamoDb only provides eventually consistent read guarantees. | ||
|
||
This eventually consistent behavior is intentional | ||
in order to optimize performance and cost. | ||
|
||
However, | ||
customers may have non-standard situations | ||
which explicitly require consistent reads to be performed. | ||
|
||
While key management operations SHOULD occur in control plane operations, | ||
those same control plane operations MAY need to perform encryption operations. | ||
|
||
Usage of consistent reads ensures that encryption operations | ||
immediately following the `CreateKey` operation | ||
will be able to find the created keys. | ||
|
||
Similarly, | ||
key rotation and re-encryption operations | ||
performed due to key compromise | ||
MAY want use consistent reads to ensure that | ||
the encryption operations utilize the new branch key version. | ||
For this to work local caches would need to be flushed as well. | ||
So this may be prohibitively complicated. | ||
|
||
However, trying to pick and chose which read operations need consistent reads | ||
creates sharp edges in complicated customer systems. | ||
So all operations MUST use the same configuration setting. | ||
|
||
# Changes | ||
|
||
The change is to introduce a new, optional `Require Consistent Reads` option | ||
to the Branch Key Store specification. | ||
|
||
This updates: | ||
|
||
- The [Branch Key Store's Initialization](../../framework/branch-key-store.md#initialization) | ||
- The [Branch Key Store's GetActiveBranchKey operation](../../framework/branch-key-store.md#getactivebranchkey) | ||
- The [Branch Key Store's GetBranchKeyVersion operation](../../framework/branch-key-store.md#getbranchkeyversion) | ||
- The [Branch Key Store's GetBeaconKey operation](../../framework/branch-key-store.md#getbeaconkey) | ||
|
||
This update clarifies the existing behavior in a backwards-compatible manner | ||
while allowing agents to opt-in to consistent reads when needed. |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For posterity, this is sometimes referred to as "read after write". Which is the specific kind of consistency we are after here.