-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix snapshot 500 error #2408
Fix snapshot 500 error #2408
Conversation
@@ -1286,6 +1243,12 @@ func (s *Server) applyDeleteShardGroup(m *messaging.Message) (err error) { | |||
s.stats.Add("shardsDeleted", int64(len(g.Shards))) | |||
return tx.saveDatabase(db) | |||
}) | |||
|
|||
// remove from lookups. | |||
for _, sh := range g.Shards { |
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.
This was causing snapshotting to break.
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.
This "lookup" map has caused me problems before. We should think about seeing if there is a way to solve the problems it is solving in another way...later, of course.
@corylanou -- when would it respond with 500? Which endpoint would return 500? |
Running this cmd:
Which called this endpoint:
|
} | ||
|
||
// ShardBySeriesID returns the shard that a series is assigned to in the group. | ||
func (g *ShardGroup) ShardBySeriesID(seriesID uint64) *Shard { | ||
return g.Shards[int(seriesID)%len(g.Shards)] | ||
func (sg *ShardGroup) ShardBySeriesID(seriesID uint64) *Shard { |
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 g
to sg
considered more idiomatic?
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.
I like the letter to typically be the first letter of the variable I'm referencing. If the variable is made of two words, I usually use the abbreviation. Idiomatic might be a strong word for this, and wasn't really the reason I did it. The real reason is that sometimes I have shards, and like to use s
for the shard variable name, and I don't want that to get confused for the ShardGroup
which also starts with an s
.
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.
+1
+1, this makes sense to me. Some small feedback. |
7742d37
to
f95dc00
Compare
I refactored the shard group creation deletion to put the shard responsibility in the shard.go file. Doing this uncovered that we were not removing the shards from the server shard map. This resulted in the snapshot trying to read closed (removed) shards and would respond with a server 500 error.