This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Bug fixes of multi_zone consumer group #170
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41a7f29
fix two multi_zone cg bugs
datoug 460fdb4
more fix
datoug 6332a02
address comments, also fix another bug in replicator reconcilation
datoug 7b56357
remove noisy log
datoug f6cdebd
add gauge metrics when no active zone is not found
datoug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -764,6 +764,7 @@ func refreshOutputHostsForConsGroup(context *Context, | |
var dstType = getDstType(dstDesc) | ||
var outputAddrs []string | ||
var outputIDs []string | ||
var consumeDisabled bool | ||
var outputHosts map[string]*common.HostInfo | ||
|
||
cgDesc, err := context.mm.ReadConsumerGroup(dstID, "", cgID, "") | ||
|
@@ -782,11 +783,12 @@ func refreshOutputHostsForConsGroup(context *Context, | |
|
||
context.resultCache.write(cgID, | ||
resultCacheParams{ | ||
dstType: dstType, | ||
nExtents: nConsumable, | ||
maxExtents: maxExtentsToConsume, | ||
hostIDs: outputIDs, | ||
expiry: now + ttl, | ||
dstType: dstType, | ||
nExtents: nConsumable, | ||
maxExtents: maxExtentsToConsume, | ||
hostIDs: outputIDs, | ||
consumeDisabled: consumeDisabled, | ||
expiry: now + ttl, | ||
}) | ||
} | ||
|
||
|
@@ -799,7 +801,8 @@ func refreshOutputHostsForConsGroup(context *Context, | |
} | ||
|
||
// If we shouldn't consume in this zone(for a multi_zone cg), short circuit and return | ||
if !shouldConsumeInZone(context.localZone, cgDesc, cfg) { | ||
if !shouldConsumeInZone(context, cgDesc, cfg) { | ||
consumeDisabled = true | ||
writeToCache(int64(outputCacheTTL)) | ||
return outputAddrs, nil | ||
} | ||
|
@@ -859,21 +862,23 @@ func refreshOutputHostsForConsGroup(context *Context, | |
// shouldConsumeInZone indicated whether we should consume from this zone for a multi_zone consumer group | ||
// If failover mode is enabled in dynamic config, the active zone will be the one specified in dynamic config | ||
// Otherwise, use the per cg override if it's specified | ||
// Last, check the active zone in dynamic config. If specified, use it. Otherwise always return true | ||
func shouldConsumeInZone(zone string, cgDesc *shared.ConsumerGroupDescription, dConfig ControllerDynamicConfig) bool { | ||
// Last, check the active zone in dynamic config. If specified, use it. Otherwise always return false | ||
func shouldConsumeInZone(context *Context, cgDesc *shared.ConsumerGroupDescription, dConfig ControllerDynamicConfig) bool { | ||
if strings.EqualFold(dConfig.FailoverMode, `enabled`) { | ||
return strings.EqualFold(zone, dConfig.ActiveZone) | ||
return strings.EqualFold(context.localZone, dConfig.ActiveZone) | ||
} | ||
|
||
if cgDesc.IsSetActiveZone() { | ||
return strings.EqualFold(zone, cgDesc.GetActiveZone()) | ||
if len(cgDesc.GetActiveZone()) > 0 { | ||
return strings.EqualFold(context.localZone, cgDesc.GetActiveZone()) | ||
} | ||
|
||
if len(dConfig.ActiveZone) > 0 { | ||
return strings.EqualFold(zone, dConfig.ActiveZone) | ||
return strings.EqualFold(context.localZone, dConfig.ActiveZone) | ||
} | ||
|
||
return true | ||
context.log.Warn(`no active zone from dynamic config !`) | ||
|
||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you also add a log or metric when both dConfig.ActiveZone and cgDesc.GetActiveZone() are empty ? |
||
} | ||
|
||
func getControllerDynamicConfig(context *Context) (ControllerDynamicConfig, error) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be a good idea to emit a metric here