Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

minor tuning #341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/metadata/metadata_cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const defaultDeleteTTLSeconds = int64(time.Hour*24*30) / int64(time.Second)

const destinationCacheSize = 1048576
const consumerGroupCacheSize = 1048576
const cacheTTL = time.Second
const cacheTTL = 5 * time.Second

// CassandraMetadataService Implements TChanMetadataServiceClient interface
// TODO: Convert all errors to the ones defined in the thrift API.
Expand Down
21 changes: 14 additions & 7 deletions services/controllerhost/controllerhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var (

const (
nEventPipelineWorkers = 2048 // most workers expected to be blocked on I/O
hashLockTableSize = 1024
hashLockTableSize = 8192
maxFailedExtentSealSetSize = 8192 // max # of failed extent seals we can keep track of
maxExtentSealsPerSecond = 200
)
Expand All @@ -108,6 +108,7 @@ type (
failureDetector Dfdd
log bark.Logger
dstLock LockMgr
cgLock LockMgr
eventPipeline EventPipeline
resultCache *resultCache
extentMonitor *extentStateMonitor
Expand Down Expand Up @@ -158,9 +159,14 @@ func NewController(cfg configure.CommonAppConfig, sVice *common.Service, metadat
deploymentName := sVice.GetConfig().GetDeploymentName()
logger := (sVice.GetConfig().GetLogger()).WithFields(bark.Fields{common.TagCtrl: common.FmtCtrl(hostID), common.TagDplName: common.FmtDplName(deploymentName)})

lockMgr, err := NewLockMgr(hashLockTableSize, common.UUIDHashCode, logger)
dstLockMgr, err := NewLockMgr(hashLockTableSize, common.UUIDHashCode, logger)
if err != nil {
logger.WithField(common.TagErr, err).Fatal(`Failed to create hash lock`)
logger.WithField(common.TagErr, err).Fatal(`Failed to create hash lock dstLockMgr`)
}

cgLockMgr, err := NewLockMgr(hashLockTableSize, common.UUIDHashCode, logger)
if err != nil {
logger.WithField(common.TagErr, err).Fatal(`Failed to create hash lock cgLockMgr`)
}

context := &Context{
Expand All @@ -172,7 +178,8 @@ func NewController(cfg configure.CommonAppConfig, sVice *common.Service, metadat
context.localZone, _ = common.GetLocalClusterInfo(strings.ToLower(deploymentName))
context.zoneFailoverManager = zoneFailoverManager

context.dstLock = lockMgr
context.dstLock = dstLockMgr
context.cgLock = cgLockMgr
context.m3Client = metrics.NewClient(instance.Service.GetMetricsReporter(), metrics.Controller)
instance.mClient = metadata.NewMetadataMetricsMgr(metadataClient, context.m3Client, context.log)
context.mm = NewMetadataMgr(instance.mClient, context.m3Client, context.log)
Expand Down Expand Up @@ -400,7 +407,7 @@ func (mcp *Mcp) GetOutputHosts(ctx thrift.Context, inReq *c.GetOutputHostsReques
return response()
}

if !context.dstLock.TryLock(dstUUID, getLockTimeout(result)) {
if !context.cgLock.TryLock(cgUUID, getLockTimeout(result)) {
context.m3Client.IncCounter(metrics.GetOutputHostsScope, metrics.ControllerErrTryLockCounter)
return response()
}
Expand All @@ -409,12 +416,12 @@ func (mcp *Mcp) GetOutputHosts(ctx thrift.Context, inReq *c.GetOutputHostsReques
// refresh the cache in the mean time
result = context.resultCache.readOutputHosts(cgUUID, now)
if result.cacheHit && !result.refreshCache {
context.dstLock.Unlock(dstUUID)
context.cgLock.Unlock(cgUUID)
return response()
}

hostIDs, err := refreshOutputHostsForConsGroup(context, dstUUID, cgUUID, *result, now)
context.dstLock.Unlock(dstUUID)
context.cgLock.Unlock(cgUUID)
if err != nil {
if isEntityError(err) {
context.m3Client.IncCounter(metrics.GetOutputHostsScope, metrics.ControllerErrBadEntityCounter)
Expand Down
2 changes: 1 addition & 1 deletion services/retentionmgr/metadataDep.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (t *metadataDepImpl) GetDestinations() (destinations []*destinationInfo, er
`status`: dest.status,
`hardRetention`: dest.hardRetention,
`softRetention`: dest.softRetention,
}).Info("GetDestinations: ListDestinationsByUUID output")
}).Debug("GetDestinations: ListDestinationsByUUID output")
}

if len(resp.GetNextPageToken()) == 0 {
Expand Down