Skip to content

Commit

Permalink
storage: Handle multi-bundle data with overlapping roots
Browse files Browse the repository at this point in the history
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 <anarkar4387@gmail.com>
  • Loading branch information
ashutosh-narkar committed Aug 17, 2022
1 parent 47c8256 commit 570c093
Show file tree
Hide file tree
Showing 7 changed files with 750 additions and 42 deletions.
10 changes: 1 addition & 9 deletions bundle/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,7 @@ func writeDataAndModules(ctx context.Context, store storage.Store, txn storage.T
}
}
} else {
var rootOverwrite bool
for _, root := range *b.Manifest.Roots {
if root == "" {
rootOverwrite = true
break
}
}

params.RootOverwrite = rootOverwrite
params.BasePaths = *b.Manifest.Roots

err := store.Truncate(ctx, txn, params, NewIterator(b.Raw))
if err != nil {
Expand Down
Loading

0 comments on commit 570c093

Please sign in to comment.