Skip to content

Commit

Permalink
storage: fix overwrite RemoteStorage factory bug
Browse files Browse the repository at this point in the history
As of this commit, if both cfg.SharedStorage and cfg.RemoteStorageFactory are
set, CRDB uses cfg.SharedStorage. Note that eventually we will enable using
both at the same time, but with the abstractions available today, that is not
easy.

We prefer cfg.SharedStorage, since the Locator -> Storage mapping contained
in it is needed for CRDB to function properly.

Release note: None.
Epic: None.
  • Loading branch information
joshimhoff committed Aug 2, 2023
1 parent 46255c8 commit f8e7dea
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/storage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,17 +1148,24 @@ func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {
opts.EventListener = &el
p.wrappedIntentWriter = wrapIntentWriter(p)

// If both cfg.SharedStorage and cfg.RemoteStorageFactory are set, CRDB uses
// cfg.SharedStorage. Note that eventually we will enable using both at the
// same time, but we don't have the right abstractions in place to do that
// today.
//
// We prefer cfg.SharedStorage, since the Locator -> Storage mapping contained
// in it is needed for CRDB to function properly.
if cfg.SharedStorage != nil {
esWrapper := &externalStorageWrapper{p: p, es: cfg.SharedStorage, ctx: ctx}
opts.Experimental.RemoteStorage = remote.MakeSimpleFactory(map[remote.Locator]remote.Storage{
"": esWrapper,
})
opts.Experimental.CreateOnShared = true
opts.Experimental.CreateOnSharedLocator = ""
}

if cfg.RemoteStorageFactory != nil {
opts.Experimental.RemoteStorage = remoteStorageAdaptor{p: p, ctx: ctx, factory: cfg.RemoteStorageFactory}
} else {
if cfg.RemoteStorageFactory != nil {
opts.Experimental.RemoteStorage = remoteStorageAdaptor{p: p, ctx: ctx, factory: cfg.RemoteStorageFactory}
}
}

// Read the current store cluster version.
Expand Down

0 comments on commit f8e7dea

Please sign in to comment.