Skip to content

Commit 060cbd4

Browse files
craig[bot]jeffswenson
andcommitted
Merge #156715
156715: logical: fix handling of tenants r=jeffswenson a=jeffswenson The legacy sql writer and the kv writer both have this logic for stripping tenant prefixes before decoding the key. This was uncovered because #156510 enabled metamorphic multi-tenancy for the LDR tests. Release note: none Fixes: #156640 Co-authored-by: Jeff Swenson <[email protected]>
2 parents 00ea203 + 34971ee commit 060cbd4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/crosscluster/logical/event_decoder.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/cdcevent"
1313
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
14+
"github.com/cockroachdb/cockroach/pkg/keys"
1415
"github.com/cockroachdb/cockroach/pkg/repstream/streampb"
1516
"github.com/cockroachdb/cockroach/pkg/roachpb"
1617
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
@@ -136,6 +137,13 @@ func (d *eventDecoder) decodeAndCoalesceEvents(
136137
if discard == jobspb.LogicalReplicationDetails_DiscardAllDeletes && event.KeyValue.Value.RawBytes == nil {
137138
continue
138139
}
140+
141+
var err error
142+
event.KeyValue.Key, err = keys.StripTenantPrefix(event.KeyValue.Key)
143+
if err != nil {
144+
return nil, errors.Wrap(err, "failed to strip tenant prefix")
145+
}
146+
139147
toDecode = append(toDecode, event)
140148
}
141149

pkg/sql/sqlclustersettings/clustersettings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var LDRImmediateModeWriter = settings.RegisterStringSetting(
145145
"logical_replication.consumer.immediate_mode_writer",
146146
"the writer to use when in immediate mode",
147147
// TODO(jeffswenson): make the crud writer the default
148-
metamorphic.ConstantWithTestChoice("logical_replication.consumer.immediate_mode_writer", string(LDRWriterTypeLegacyKV), string(LDRWriterTypeSQL)),
148+
metamorphic.ConstantWithTestChoice("logical_replication.consumer.immediate_mode_writer", string(LDRWriterTypeLegacyKV), string(LDRWriterTypeCRUD), string(LDRWriterTypeSQL)),
149149
settings.WithValidateString(func(sv *settings.Values, val string) error {
150150
if val != string(LDRWriterTypeSQL) && val != string(LDRWriterTypeLegacyKV) && val != string(LDRWriterTypeCRUD) {
151151
return errors.Newf("immediate mode writer must be either 'sql', 'legacy-kv', or 'crud', got '%s'", val)

0 commit comments

Comments
 (0)