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

Add timeout option to SQL CLI tool. #153

Merged
merged 2 commits into from
Nov 15, 2022

Conversation

Yury-Fridlyand
Copy link

Signed-off-by: Yury-Fridlyand [email protected]

Description

Add response timeout option to SQL CLI tool. This is very handy for SQL plugin debugging purposes.
Imagine you are debugging a query and placed a breakpoint into the plugin code. While you are going step-by-step debugging, CLI times out.

New command line optional argument added:

-t <value in seconds>

If not given, SQL CLI works as usual. Default timeout is 10 sec.

Before

$ opensearchsql
...
opensearchsql> select 1;
fetched rows / total rows = 1/1      <--- response in 0-10 sec
+-----+
| 1   |
|-----|
| 1   |
+-----+
opensearchsql> select 1;
Reconnecting...
Reconnected! Please run query again      <--- response in 10-19 sec
opensearchsql> select 1;
Reconnecting...
Connection Failed. Check your OpenSearch is running and then come back     <---- 20+ sec
ConnectionTimeout('TIMEOUT', "HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=10)", ReadTimeoutError("HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=10)"))
opensearchsql>

After

$ opensearchsql -t 10000
...
opensearchsql> select 1;
fetched rows / total rows = 1/1          <---- 30 min of intensive debugging with breaks - no timeout!
+-----+
| 1   |
|-----|
| 1   |
+-----+

Parameter request_timeout is processed by underlying library:
https://github.com/opensearch-project/opensearch-py/blob/8879644ec404b3ab15b739b97775d7bd7e51018b/opensearchpy/transport.py#L457

How to test

Ref: https://github.com/opensearch-project/sql/blob/2.x/sql-cli/development_guide.md#development-environment-set-up

Do once:

cd sql-cli
pip install virtualenv
virtualenv venv
pip install --editable .

Then every time you want to debug SQL CLI:

<checkout>
cd sql-cli
source ./venv/bin/activate

To exit from venv:

deactivate

You can run SQL CLI and switch branch. It will keep working with given timeout until closed.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov

This comment was marked as abuse.

Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand marked this pull request as ready for review November 2, 2022 01:38
@GumpacG
Copy link

GumpacG commented Nov 3, 2022

The code coverage went down 2.64%. Is this a concern?

@Yury-Fridlyand
Copy link
Author

The code coverage went down 2.64%. Is this a concern?

It is code coverage for java code and it works terrible [on our repo].

Copy link

@MitchellGale MitchellGale left a comment

Choose a reason for hiding this comment

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

Great change.

@Yury-Fridlyand Yury-Fridlyand merged commit ca8ae7b into integ-timeout-cli Nov 15, 2022
@Yury-Fridlyand Yury-Fridlyand deleted the dev-timeout-cli branch November 15, 2022 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants