Skip to content
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

Remove "shouldn't happen" condition #122

Merged
merged 1 commit into from
Nov 8, 2016
Merged
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
21 changes: 6 additions & 15 deletions ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,27 +479,18 @@ func (i *Ingester) flushAllUsers(immediate bool) {
}

i.userStateLock.Lock()
userIDs := make([]string, 0, len(i.userState))
for userID := range i.userState {
userIDs = append(userIDs, userID)
userState := make(map[string]*userState, len(i.userState))
for id, state := range i.userState {
userState[id] = state
}
i.userStateLock.Unlock()

for _, userID := range userIDs {
i.flushUser(userID, immediate)
for id, state := range userState {
i.flushUser(id, state, immediate)
}
}

func (i *Ingester) flushUser(userID string, immediate bool) {
i.userStateLock.Lock()
userState, ok := i.userState[userID]
i.userStateLock.Unlock()

// This should happen, right?
if !ok {
return
}

func (i *Ingester) flushUser(userID string, userState *userState, immediate bool) {
for pair := range userState.fpToSeries.iter() {
i.flushSeries(userState, pair.fp, pair.series, immediate)
}
Expand Down