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

Errors when handle concurrent requests [BUG] #196

Closed
mengweieric opened this issue Aug 26, 2021 · 6 comments
Closed

Errors when handle concurrent requests [BUG] #196

mengweieric opened this issue Aug 26, 2021 · 6 comments
Assignees
Labels
bug Something isn't working PPL Piped processing language

Comments

@mengweieric
Copy link
Collaborator

Describe the bug
When different requests hitting the same endpoint _plugins/_ppl concurrently, sometimes all the requests get the same responses.

To Reproduce
Steps to reproduce the behavior:
If you curl endpoint with two different requests concurrently, sometimes you are getting correct responses, but sometimes you are getting the same response.

`
curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d "{ 'query': 'source=opensearch_dashboards_sample_data_flights' }" | jq ".size" & curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d '{ "query": "source=opensearch_dashboards_sample_data_flights | stats count() by span(timestamp, "1h")" }' | jq ".size"
[1] 25313 25314
1008
1008
[1] + done curl -s -H 'Content-Type: application/json' -XPOST -d | jq ".size"

curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d "{ 'query': 'source=opensearch_dashboards_sample_data_flights' }" | jq ".size" & curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d '{ "query": "source=opensearch_dashboards_sample_data_flights | stats count() by span(timestamp, "1h")" }' | jq ".size"
[1] 25334 25335
1008
200
[1] + done curl -s -H 'Content-Type: application/json' -XPOST -d | jq ".size"
`

Expected behavior
Always getting the correct responses for different requests under concurrent context.

Plugins
SQL

Host/Environment (please complete the following information):

  • OS: MacOS Catalina
  • Version 10.15.7
@mengweieric mengweieric added Beta bug Something isn't working untriaged labels Aug 26, 2021
@chloe-zh
Copy link
Contributor

I reproduced this issue in my local cluster, and located the issue within the plugin:

https://github.com/opensearch-project/sql/blob/main/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java#L163

  @Override
  protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient nodeClient) {
    ...
    return channel -> pplService.execute(pplRequest, createListener(channel));
  }

Debugged the ppl request around, and found the requests intaken by the channel are of different request instances but sometimes they have the same content.
Looks like the pplService does not handle the incoming request very well probably they are they are always consuming the same node client.

@chloe-zh chloe-zh changed the title [BUG] Errors when handle concurrent requests [BUG] Aug 27, 2021
@chloe-zh chloe-zh added PPL Piped processing language SQL and removed Beta untriaged labels Aug 27, 2021
@dai-chen dai-chen self-assigned this Sep 2, 2021
@dai-chen
Copy link
Collaborator

dai-chen commented Sep 3, 2021

@mengweieric @chloe-zh Is span function merged or still in personal branch? I tried similar commands but cannot reproduce the issue locally. Could you share which OpenSearch version and branch was used? Thanks!

@chloe-zh
Copy link
Contributor

chloe-zh commented Sep 3, 2021

@dai-chen Hi Chen, the span is in personal branch, but it seems not related to the span functionality, because I didn't use the branch but also reproduced the issue. Here is the command I used with curl in cli:

curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d "{ 'query': 'source=opensearch_dashboards_sample_data_flights' }" | jq ".size" & curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d '{ "query": "source=opensearch_dashboards_sample_data_flights | stats count()" }' | jq ".size"

@chloe-zh
Copy link
Contributor

chloe-zh commented Sep 3, 2021

@dai-chen
Copy link
Collaborator

dai-chen commented Sep 3, 2021

@dai-chen Hi Chen, the span is in personal branch, but it seems not related to the span functionality, because I didn't use the branch but also reproduced the issue. Here is the command I used with curl in cli:

curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d "{ 'query': 'source=opensearch_dashboards_sample_data_flights' }" | jq ".size" & curl -s -H 'Content-Type: application/json' -XPOST localhost:9200/_plugins/_ppl -d '{ "query": "source=opensearch_dashboards_sample_data_flights | stats count()" }' | jq ".size"

Okay, I tried same command on different index but cannot reproduce the issue. Will double check the code. Thanks!

@dai-chen
Copy link
Collaborator

The root cause seems here: https://github.com/opensearch-project/sql/blob/main/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java#L100

For some reason, pplRequest is field member instead of a local variable in method. Remove it and the concurrent issue seems gone. Will prepare PR once confirmed.

@dai-chen dai-chen removed the SQL label Sep 15, 2021
penghuo pushed a commit that referenced this issue Jan 6, 2023
)

Added Testing And Implementation For Minute_Of_Hour Function

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this issue Jan 6, 2023
)

Added Testing And Implementation For Minute_Of_Hour Function

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
(cherry picked from commit 61e2374)
penghuo pushed a commit that referenced this issue Jan 9, 2023
…tion (#1253)

* Add Minute_Of_Hour Function As An Alias Of Minute Function (#196) (#1230)

Added Testing And Implementation For Minute_Of_Hour Function

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
(cherry picked from commit 61e2374)

* Added Missing Imports

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
penghuo added a commit that referenced this issue Jan 10, 2023
* Add BWC tests for running against distribution bundle.  (#1209)

Signed-off-by: Zelin Hao <[email protected]>

* Add Alternate Syntax For Match_Query And Other Functions (#1166)

Added Tests And Implementation For Match_Query, Match_Phrase, and Multi_Match Functions

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>

* Merge pull request #1241 from Bit-Quill/Failing-CI-Hot-Fix

Hot Fix For CI Build

(cherry picked from commit aae57a0)
Signed-off-by: GabeFernandez310 <[email protected]>

* Fixed error with single timestamp query (#1244) (#1246)

Signed-off-by: vamsi-amazon <[email protected]>

Signed-off-by: vamsi-amazon <[email protected]>
(cherry picked from commit ee949cc)

Co-authored-by: vamsi-amazon <[email protected]>

* Add Second_Of_Minute Function As An Alias Of The Second Function (#1231) (#1237)

Added Testing And Implementation For Second_Of_Minute Function

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
(cherry picked from commit dce7d0e)

Co-authored-by: GabeFernandez310 <[email protected]>

* Add functions `ADDTIME` and `SUBTIME`. (#132) (#1194) (#1252)

* Add functions `ADDTIME` and `SUBTIME`. (#132)

Signed-off-by: Yury-Fridlyand <[email protected]>
(cherry picked from commit 7630f87)

Co-authored-by: Yury-Fridlyand <[email protected]>

* Add Day_Of_Week Function As An Alias Of DayOfWeek (#190) (#1228) (#1239)

Added Implementation And Testing For Day_Of_Week Function

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
(cherry picked from commit bac9c37)

Co-authored-by: GabeFernandez310 <[email protected]>

* [Backport 2.x] Add Minute_Of_Hour Function As An Alias Of Minute Function (#1253)

* Add Minute_Of_Hour Function As An Alias Of Minute Function (#196) (#1230)

Added Testing And Implementation For Minute_Of_Hour Function

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>
(cherry picked from commit 61e2374)

* Added Missing Imports

Signed-off-by: GabeFernandez310 <[email protected]>

Signed-off-by: GabeFernandez310 <[email protected]>

* Add support for long value return for CEIL, CEILING and FLOOR math functions (#1205) (#1255)

* Added long fix for CEIL, CEILING and FLOOR functions using LONG instead of INT for RETURN.

Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>

* Support JOIN query on object field with unexpanded name (#1229) (#1250)

* Resolve sub object field in search hit source

Signed-off-by: Chen Dai <[email protected]>

* Rename to unexpanded object

Signed-off-by: Chen Dai <[email protected]>

* Update IT with where condition

Signed-off-by: Chen Dai <[email protected]>

* Fix test index mapping

Signed-off-by: Chen Dai <[email protected]>

Signed-off-by: Chen Dai <[email protected]>
(cherry picked from commit 151f4cc)

Co-authored-by: Chen Dai <[email protected]>

* Remove unnecessary scripts after repo split (#1256)

Signed-off-by: Joshua Li <[email protected]>

* Add Support For `TIME` Type in "*_OF_YEAR" Functions (#199) (#1223) (#1258)

Added Support And Tests For Time Type in day_of_year, week_of_year, month_of_year Functions
Signed-off-by: GabeFernandez310 <[email protected]>
(cherry picked from commit 6e72f18)

Co-authored-by: GabeFernandez310 <[email protected]>

Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Joshua Li <[email protected]>
Co-authored-by: Zelin Hao <[email protected]>
Co-authored-by: GabeFernandez310 <[email protected]>
Co-authored-by: YANGDB <[email protected]>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: vamsi-amazon <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Co-authored-by: GabeFernandez310 <[email protected]>
Co-authored-by: Chen Dai <[email protected]>
Co-authored-by: Joshua Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PPL Piped processing language
Projects
None yet
Development

No branches or pull requests

3 participants