From e493f3cd80350ddce7937a53e264ab9b7604d325 Mon Sep 17 00:00:00 2001 From: Anish Adhikari Date: Fri, 30 Oct 2020 14:13:51 -0700 Subject: [PATCH] Revert datablob change from manager/store for metaData store (#3706) Co-authored-by: Andrew Dawson --- .../cassandraMetadataPersistenceV2.go | 19 +--------- common/persistence/metadataStore.go | 17 ++++++++- common/persistence/persistenceInterface.go | 2 +- .../persistence/sql/sqlMetadataManagerV2.go | 37 +++++-------------- 4 files changed, 27 insertions(+), 48 deletions(-) diff --git a/common/persistence/cassandra/cassandraMetadataPersistenceV2.go b/common/persistence/cassandra/cassandraMetadataPersistenceV2.go index 9f685b23d03..bac90e92829 100644 --- a/common/persistence/cassandra/cassandraMetadataPersistenceV2.go +++ b/common/persistence/cassandra/cassandraMetadataPersistenceV2.go @@ -31,7 +31,6 @@ import ( "github.com/uber/cadence/common/persistence/nosql/nosqlplugin" "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra" "github.com/uber/cadence/common/service/config" - "github.com/uber/cadence/common/types/mapper/thrift" ) const ( @@ -42,7 +41,6 @@ type ( nosqlDomainManager struct { nosqlManager currentClusterName string - serializer p.PayloadSerializer } ) @@ -60,7 +58,6 @@ func newMetadataPersistenceV2(cfg config.Cassandra, currentClusterName string, l logger: logger, }, currentClusterName: currentClusterName, - serializer: p.NewPayloadSerializer(), }, nil } @@ -297,13 +294,6 @@ func (m *nosqlDomainManager) GetMetadata( func (m *nosqlDomainManager) toNoSQLInternalDomainConfig( domainConfig *p.InternalDomainConfig, ) (*nosqlplugin.NoSQLInternalDomainConfig, error) { - serializedBadBinaries, err := m.serializer.SerializeBadBinaries( - thrift.FromBadBinaries(&domainConfig.BadBinaries), - common.EncodingTypeThriftRW) - if err != nil { - return nil, err - } - return &nosqlplugin.NoSQLInternalDomainConfig{ Retention: domainConfig.Retention, EmitMetric: domainConfig.EmitMetric, @@ -313,18 +303,13 @@ func (m *nosqlDomainManager) toNoSQLInternalDomainConfig( HistoryArchivalURI: domainConfig.HistoryArchivalURI, VisibilityArchivalStatus: domainConfig.VisibilityArchivalStatus, VisibilityArchivalURI: domainConfig.VisibilityArchivalURI, - BadBinaries: p.NewDataBlob(serializedBadBinaries.Data, serializedBadBinaries.Encoding), + BadBinaries: domainConfig.BadBinaries, }, nil } func (m *nosqlDomainManager) fromNoSQLInternalDomainConfig( domainConfig *nosqlplugin.NoSQLInternalDomainConfig, ) (*p.InternalDomainConfig, error) { - badBinaries, err := m.serializer.DeserializeBadBinaries(domainConfig.BadBinaries) - if err != nil { - return nil, err - } - return &p.InternalDomainConfig{ Retention: domainConfig.Retention, EmitMetric: domainConfig.EmitMetric, @@ -334,6 +319,6 @@ func (m *nosqlDomainManager) fromNoSQLInternalDomainConfig( HistoryArchivalURI: domainConfig.HistoryArchivalURI, VisibilityArchivalStatus: domainConfig.VisibilityArchivalStatus, VisibilityArchivalURI: domainConfig.VisibilityArchivalURI, - BadBinaries: *thrift.ToBadBinaries(badBinaries), + BadBinaries: domainConfig.BadBinaries, }, nil } diff --git a/common/persistence/metadataStore.go b/common/persistence/metadataStore.go index 63cee193db3..763ae550942 100644 --- a/common/persistence/metadataStore.go +++ b/common/persistence/metadataStore.go @@ -23,6 +23,8 @@ package persistence import ( "context" + "github.com/uber/cadence/common" + "github.com/uber/cadence/.gen/go/shared" "github.com/uber/cadence/common/log" "github.com/uber/cadence/common/types/mapper/thrift" @@ -177,6 +179,10 @@ func (m *metadataManagerImpl) toInternalDomainConfig(c *DomainConfig) (InternalD if c.BadBinaries.Binaries == nil { c.BadBinaries.Binaries = map[string]*shared.BadBinaryInfo{} } + badBinaries, err := m.serializer.SerializeBadBinaries(&c.BadBinaries, common.EncodingTypeThriftRW) + if err != nil { + return InternalDomainConfig{}, err + } return InternalDomainConfig{ Retention: c.Retention, EmitMetric: c.EmitMetric, @@ -184,7 +190,7 @@ func (m *metadataManagerImpl) toInternalDomainConfig(c *DomainConfig) (InternalD HistoryArchivalURI: c.HistoryArchivalURI, VisibilityArchivalStatus: *thrift.ToArchivalStatus(&c.VisibilityArchivalStatus), VisibilityArchivalURI: c.VisibilityArchivalURI, - BadBinaries: *thrift.ToBadBinaries(&c.BadBinaries), + BadBinaries: badBinaries, }, nil } @@ -192,6 +198,13 @@ func (m *metadataManagerImpl) fromInternalDomainConfig(ic *InternalDomainConfig) if ic == nil { return DomainConfig{}, nil } + badBinaries, err := m.serializer.DeserializeBadBinaries(ic.BadBinaries) + if err != nil { + return DomainConfig{}, err + } + if badBinaries.Binaries == nil { + badBinaries.Binaries = map[string]*shared.BadBinaryInfo{} + } return DomainConfig{ Retention: ic.Retention, EmitMetric: ic.EmitMetric, @@ -199,7 +212,7 @@ func (m *metadataManagerImpl) fromInternalDomainConfig(ic *InternalDomainConfig) HistoryArchivalURI: ic.HistoryArchivalURI, VisibilityArchivalStatus: *thrift.FromArchivalStatus(&ic.VisibilityArchivalStatus), VisibilityArchivalURI: ic.VisibilityArchivalURI, - BadBinaries: *thrift.FromBadBinaries(&ic.BadBinaries), + BadBinaries: *badBinaries, }, nil } diff --git a/common/persistence/persistenceInterface.go b/common/persistence/persistenceInterface.go index 86e7d6fab08..139153fec95 100644 --- a/common/persistence/persistenceInterface.go +++ b/common/persistence/persistenceInterface.go @@ -747,7 +747,7 @@ type ( HistoryArchivalURI string VisibilityArchivalStatus types.ArchivalStatus VisibilityArchivalURI string - BadBinaries types.BadBinaries + BadBinaries *DataBlob } // InternalCreateDomainRequest is used to create the domain diff --git a/common/persistence/sql/sqlMetadataManagerV2.go b/common/persistence/sql/sqlMetadataManagerV2.go index 50b01eaf33a..fda5f7a4df4 100644 --- a/common/persistence/sql/sqlMetadataManagerV2.go +++ b/common/persistence/sql/sqlMetadataManagerV2.go @@ -25,22 +25,19 @@ import ( "database/sql" "fmt" - "github.com/uber/cadence/common/persistence/serialization" - "github.com/uber/cadence/common/types" - "github.com/uber/cadence/common/types/mapper/thrift" - workflow "github.com/uber/cadence/.gen/go/shared" "github.com/uber/cadence/.gen/go/sqlblobs" "github.com/uber/cadence/common" "github.com/uber/cadence/common/log" "github.com/uber/cadence/common/persistence" + "github.com/uber/cadence/common/persistence/serialization" "github.com/uber/cadence/common/persistence/sql/sqlplugin" + "github.com/uber/cadence/common/types" ) type sqlMetadataManagerV2 struct { sqlStore activeClusterName string - serializer persistence.PayloadSerializer } // newMetadataPersistenceV2 creates an instance of sqlMetadataManagerV2 @@ -56,7 +53,6 @@ func newMetadataPersistenceV2( logger: logger, parser: parser, }, - serializer: persistence.NewPayloadSerializer(), activeClusterName: currentClusterName, }, nil } @@ -109,15 +105,10 @@ func (m *sqlMetadataManagerV2) CreateDomain( var badBinaries []byte var badBinariesEncoding *string - - serializedBadBinaries, err := m.serializer.SerializeBadBinaries( - thrift.FromBadBinaries(&request.Config.BadBinaries), - common.EncodingTypeThriftRW) - if err != nil { - return nil, err + if request.Config.BadBinaries != nil { + badBinaries = request.Config.BadBinaries.Data + badBinariesEncoding = common.StringPtr(string(request.Config.BadBinaries.GetEncoding())) } - badBinaries = serializedBadBinaries.Data - badBinariesEncoding = common.StringPtr(string(serializedBadBinaries.GetEncoding())) domainInfo := &sqlblobs.DomainInfo{ Status: common.Int32Ptr(int32(request.Info.Status)), @@ -240,10 +231,6 @@ func (m *sqlMetadataManagerV2) domainRowToGetDomainResponse(row *sqlplugin.Domai if domainInfo.BadBinaries != nil { badBinaries = persistence.NewDataBlob(domainInfo.BadBinaries, common.EncodingType(*domainInfo.BadBinariesEncoding)) } - deserializedBadBinaries, err := m.serializer.DeserializeBadBinaries(badBinaries) - if err != nil { - return nil, err - } var failoverEndTime *int64 if domainInfo.IsSetFailoverEndTime() { @@ -268,7 +255,7 @@ func (m *sqlMetadataManagerV2) domainRowToGetDomainResponse(row *sqlplugin.Domai HistoryArchivalURI: domainInfo.GetHistoryArchivalURI(), VisibilityArchivalStatus: types.ArchivalStatus(*domainInfo.VisibilityArchivalStatus), VisibilityArchivalURI: domainInfo.GetVisibilityArchivalURI(), - BadBinaries: *thrift.ToBadBinaries(deserializedBadBinaries), + BadBinaries: badBinaries, }, ReplicationConfig: &persistence.DomainReplicationConfig{ ActiveClusterName: persistence.GetOrUseDefaultActiveCluster(m.activeClusterName, domainInfo.GetActiveClusterName()), @@ -297,17 +284,11 @@ func (m *sqlMetadataManagerV2) UpdateDomain( var badBinaries []byte var badBinariesEncoding *string - - serializedBadBinaries, err := m.serializer.SerializeBadBinaries( - thrift.FromBadBinaries(&request.Config.BadBinaries), - common.EncodingTypeThriftRW) - if err != nil { - return err + if request.Config.BadBinaries != nil { + badBinaries = request.Config.BadBinaries.Data + badBinariesEncoding = common.StringPtr(string(request.Config.BadBinaries.GetEncoding())) } - badBinaries = serializedBadBinaries.Data - badBinariesEncoding = common.StringPtr(string(serializedBadBinaries.GetEncoding())) - var failoverEndTime *int64 if request.FailoverEndTime != nil { failoverEndTime = request.FailoverEndTime