New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refine update partition stats mechanism(#32446) #32768
refine update partition stats mechanism(#32446) #32768
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MrPresent-Han The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
c6a093a
to
61dbb3c
Compare
|
||
req := &querypb.SyncDistributionRequest{ | ||
Base: commonpbutil.NewMsgBase( | ||
commonpbutil.WithMsgType(commonpb.MsgType_LoadSegments), |
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.
is thisMsgType_LoadSegments right?
} | ||
log := log.Ctx(ctx) | ||
for partID, newVersion := range partStatsVersions { | ||
curStats, exist := sd.partitionStats[partID] |
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.
need RWLock ?
Signed-off-by: MrPresent-Han <[email protected]>
61dbb3c
to
aa342d0
Compare
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.
review for second time
@@ -206,14 +207,35 @@ func (h *ServerHandler) GetQueryVChanPositions(channel RWChannel, partitionIDs . | |||
// unindexed is flushed segments as well | |||
indexedIDs.Insert(unIndexedIDs.Collect()...) | |||
|
|||
// update partition stats versions |
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.
when there are too many partitions and multiple versions of partition stats are avaiable to single partition, this part can consume loads of cpu cycles, no mentioning it includes string prefix compare
log.Info("update partition stats versions") | ||
sd.loadPartitionStats(ctx, partVersions) | ||
} | ||
|
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.
Rlock protect get GetPartitionStatsVersions.
WLock protection is inside loadPartitionStats(ctx, partVersions)
func() { | ||
sd.partitionStatsMut.RLock() | ||
defer sd.partitionStatsMut.RUnlock() | ||
partStats, exists = sd.partitionStats[partID] |
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.
only use mutex in the last step when upgrading the underlying partition stats in the memory to avoid blocking search process for slow s3-read process
related: #32446