Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

[R4R]add option to enable range query for tx indexer;add option to disable websocket #115

Merged
merged 4 commits into from
Sep 10, 2019

Conversation

unclezoro
Copy link
Collaborator

@unclezoro unclezoro commented Sep 9, 2019

resolve issue #114

Description

more connection error between node and kafka should be taken into consideration

sarama didn't wrap tcp connection error. We need categorize them into retryable error so that downstream service cannot miss message.

Rationale

  1. for now, tx_search API may take a very long time and huge memory to execute a range query. Have a DDOS issue.
  2. We would like to have an option to disable WebSocket server when someone attack our dataseed through websocket, we can shut it down and restserver still works.

Example

➜  build git:(2f965c9) ✗ curl '127.0.0.1:26657/tx_search?query="tx.height>733"'
{
  "jsonrpc": "2.0",
  "id": "",
  "error": {
    "code": -32603,
    "message": "Internal error",
    "data": "range query is not supported by this node, detected invalid operators['>', '<', '<=', '>='] in the query statement"
  }
}%  

\u003e means >.

if disable websocket server:
image

Changes

Code tidy up

Preflight checks

  • build passed (make build)
  • tests passed (make test)

Already reviewed by

...

Related issues

#114

@unclezoro unclezoro changed the base branch from master to develop September 9, 2019 10:57
@unclezoro unclezoro changed the title [R4R]add option to enable range query for tx indexer;add option to disable… [R4R]add option to enable range query for tx indexer;add option to disable websocket Sep 9, 2019
@@ -169,6 +177,18 @@ func (txi *TxIndex) Search(q *query.Query) ([]*types.TxResult, error) {
// if both upper and lower bounds exist, it's better to get them in order not
// no iterate over kvs that are not within range.
ranges, rangeIndexes := lookForRanges(conditions)
if !txi.enableRangeQuery && len(rangeIndexes) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to find the operator, just print the query

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -169,6 +177,10 @@ func (txi *TxIndex) Search(q *query.Query) ([]*types.TxResult, error) {
// if both upper and lower bounds exist, it's better to get them in order not
Copy link
Contributor

@rickyyangz rickyyangz Sep 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought, we may check strings.ContainsAny(s, "><") before we parse the query conditions.

@unclezoro unclezoro merged commit 39d4561 into develop Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants