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
Bug fixes elastic search indexer #1997
Conversation
if err != nil { | ||
log.Warn("indexer: response body", | ||
"body", string(responseBody)) | ||
log.Warn("indexer:cannot read from response body", "error", err) |
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.
return nil, err here
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.
done.
@@ -104,16 +104,16 @@ func (ei *elasticIndexer) SaveBlock( | |||
} | |||
|
|||
txsSizeInBytes := computeSizeOfTxs(ei.marshalizer, txPool) | |||
go ei.database.SaveHeader(headerHandler, signersIndexes, body, notarizedHeadersHashes, txsSizeInBytes) | |||
ei.database.SaveHeader(headerHandler, signersIndexes, body, notarizedHeadersHashes, txsSizeInBytes) |
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.
may be leave to go routines - add a go routine throttler ?
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.
for the moment i will let as it is because method SaveBlock is called on a goroutine and i want the writing of header, miniblocks and transaction to be serial because this write do a lot of requests to elasticsearch database because have to check if miniblocks and transactions exits in database.
var responseBody []byte | ||
responseBody, err = ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
log.Warn("indexer: response body", |
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.
You should delete this Warn, as responeBody should be nil if err != nil. Did you want to log res.Body? If you want to keep this warn you can add it in the next warn as additional info:
log.Warn("indexer:cannot read from response body", "body", string(responseBody), "error", err)
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.
done.
var decodedBody object | ||
if err := json.NewDecoder(res.Body).Decode(&decodedBody); err != nil { | ||
if err := json.Unmarshal(responseBody, &decodedBody); err != nil { | ||
log.Warn("indexer: response body", |
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.
Delete this warn and add it in the next Warn as additional info, like suggested above
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.
body
txsPool[hashes[i]] = &txs[i] | ||
} | ||
for i := 0; i < 1000; i++ { | ||
numTransactions := 1 |
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.
Move these two lines outside the for
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.
done.
} | ||
header := &dataBlock.Header{} | ||
txsPool := make(map[string]data.TransactionHandler) | ||
for i := 0; i < numTransactions; i++ { |
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.
Use j instead i. The outer for uses also i for iteration
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.
done.
TxHashes: make([][]byte, numTransactions), | ||
Type: dataBlock.TxBlock, | ||
} | ||
for i := 0; i < numTransactions; i++ { |
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.
Use j instead i. The outer for uses also i for iteration
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.
done.
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.
System tests passed.
No description provided.