Skip to content

Commit f8e7dea

Browse files
committed
storage: fix overwrite RemoteStorage factory bug
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.
1 parent 46255c8 commit f8e7dea

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pkg/storage/pebble.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,17 +1148,24 @@ func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {
11481148
opts.EventListener = &el
11491149
p.wrappedIntentWriter = wrapIntentWriter(p)
11501150

1151+
// If both cfg.SharedStorage and cfg.RemoteStorageFactory are set, CRDB uses
1152+
// cfg.SharedStorage. Note that eventually we will enable using both at the
1153+
// same time, but we don't have the right abstractions in place to do that
1154+
// today.
1155+
//
1156+
// We prefer cfg.SharedStorage, since the Locator -> Storage mapping contained
1157+
// in it is needed for CRDB to function properly.
11511158
if cfg.SharedStorage != nil {
11521159
esWrapper := &externalStorageWrapper{p: p, es: cfg.SharedStorage, ctx: ctx}
11531160
opts.Experimental.RemoteStorage = remote.MakeSimpleFactory(map[remote.Locator]remote.Storage{
11541161
"": esWrapper,
11551162
})
11561163
opts.Experimental.CreateOnShared = true
11571164
opts.Experimental.CreateOnSharedLocator = ""
1158-
}
1159-
1160-
if cfg.RemoteStorageFactory != nil {
1161-
opts.Experimental.RemoteStorage = remoteStorageAdaptor{p: p, ctx: ctx, factory: cfg.RemoteStorageFactory}
1165+
} else {
1166+
if cfg.RemoteStorageFactory != nil {
1167+
opts.Experimental.RemoteStorage = remoteStorageAdaptor{p: p, ctx: ctx, factory: cfg.RemoteStorageFactory}
1168+
}
11621169
}
11631170

11641171
// Read the current store cluster version.

0 commit comments

Comments
 (0)