Skip to content
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

storage: Handle multi-bundle data with overlapping roots #5005

Merged

Conversation

ashutosh-narkar
Copy link
Member

If the bundles being activated share a manifest root prefix, it
would result in overwriting the bundle data based on the activation
order. This happened since the truncate call writes data to the
store based on the top-level keys in the data. When multiple
bundles with overlapping bundle root prefixes are being activated
as part of the same txn, adding data to the store by iterating
over the top-level keys in the data object would result in an unintended
overwrite. The truncate call would be able to properly write
data if it had knowledge of the bundle roots. This commit passes
the bundle roots to the truncate call to assist in writing data
to the store.

Fixes: #4998

Signed-off-by: Ashutosh Narkar [email protected]

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- One question regarding backwards-compatibility and if we do (and need to) break it.

// BasePaths indicates the top-level paths where write operations will be performed in this transaction.
BasePaths []string

// RootOverwrite is deprecated. Use BasePaths instead.
RootOverwrite bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would code using the TransactionParams before now break because BasePaths doesn't equal ""? Or do we handle that backwards-compatibly via RootOverwrite? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We can support backwards-compatibly via RootOverwrite for now and then remove it in a future release. Updated the code.

@ashutosh-narkar ashutosh-narkar force-pushed the root-overlap-fix branch 3 times, most recently from 8fa094c to b7c2b0e Compare August 16, 2022 20:24
Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one question

storage/inmem/inmem.go Show resolved Hide resolved
If the bundles being activated share a manifest root prefix, it
would result in overwriting the bundle data based on the activation
order. This happened since the truncate call writes data to the
store based on the top-level keys in the data. When multiple
bundles with overlapping bundle root prefixes are being activated
as part of the same txn, adding data to the store by iterating
over the top-level keys in the data object would result in an unintended
overwrite. The truncate call would be able to properly write
data if it had knowledge of the bundle roots. This commit passes
the bundle roots to the truncate call to assist in writing data
to the store.

Fixes: open-policy-agent#4998

Signed-off-by: Ashutosh Narkar <[email protected]>
@ashutosh-narkar ashutosh-narkar merged commit 570c093 into open-policy-agent:main Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading partially overlapping data from multiple bundles results incorrect state
2 participants