-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 elasticsearch create index race condition error #641
Fix elasticsearch create index race condition error #641
Conversation
4c68035
to
1f21f99
Compare
_, err := s.client.CreateIndex(indexName).Body(s.fixMapping(mapping)).Do(s.ctx) | ||
s.writerMetrics.indexCreate.Emit(err, time.Since(start)) | ||
if err != nil { | ||
return s.logError(jsonSpan, err, "Failed to create index", s.logger) | ||
eErr, ok := err.(*elastic.Error) | ||
if !ok || eErr.Details.Type != "index_already_exists_exception" { |
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.
can Details be null?
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.
null check added
@@ -140,12 +141,15 @@ func (s *SpanWriter) createIndex(indexName string, mapping string, jsonSpan *jMo | |||
exists, _ := s.client.IndexExists(indexName).Do(s.ctx) // don't need to check the error because the exists variable will be false anyway if there is an error | |||
if !exists { | |||
// if there are multiple collectors writing to the same elasticsearch host, if the collectors pass |
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 whole sentence is kinda wonky now.
"if there are multiple collectors attempting to create the same index at once, we make sure the error is not index_already_exists_exception or else we return the error"
or something to that effect
3119246
to
b64071b
Compare
Changes Unknown when pulling b64071b on pavolloffay:fix-es-index-race-condition into ** on jaegertracing:master**. |
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
b64071b
to
bedac86
Compare
Fixes #589