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

Sending multiple queries in a single API call broken in 2.4 #214

Closed
skovzhaw opened this issue Oct 25, 2016 · 8 comments
Closed

Sending multiple queries in a single API call broken in 2.4 #214

skovzhaw opened this issue Oct 25, 2016 · 8 comments

Comments

@skovzhaw
Copy link

skovzhaw commented Oct 25, 2016

Sending multiple queries to InfluxDB in a single API call is broken in 2.4 (delimiting each query using a semicolon, see example). It only returns the first result, where in 2.3 it worked flawlessly.

Guys, what has changed?

@majst01
Copy link
Collaborator

majst01 commented Oct 25, 2016

Can you write a test which shows this behavior ? This is actually not part of our unit-test otherwise it would have been seen.

@bentatham any ideas ?

@majst01
Copy link
Collaborator

majst01 commented Oct 31, 2016

Any updates on this, as this scares me a bit.

@bentatham
Copy link
Contributor

Nothing comes to mind. I don't seen anything explicit in the code about separating based on ;, so it must have all been implicitly. I suppose something might have changed in the switch to moshi when unmarshalling the json response back to java, but not sure what. We need to add a test case for this for sure.

@skovzhaw
Copy link
Author

skovzhaw commented Nov 1, 2016

Any ETA on fixing this? One of our use cases relies on it quite heavily. Thanks in advance

@shanexu
Copy link
Contributor

shanexu commented Nov 8, 2016

okhttp does not encode ; into %3B. Then influxdb will only execute the first query command.
for example

curl "http://127.0.0.1:8086/query?db=testdb&q=select%20*%20from%20notexist%3Bselect%20*%20from%20notexist"

the result should be

{"results":[{},{}]}

but with influxdb-java the result is

{"results":[{}]}

@majst01
Copy link
Collaborator

majst01 commented Nov 8, 2016

Is this on the request or response side ?

@shanexu
Copy link
Contributor

shanexu commented Nov 8, 2016

the request side.
influxdb-java 2.3 using okhttp 2.7.5, and okhttp 2.7.5 using URLEncoder.encode encode query string, so there's no problem.
but influxdb-java 2.4 using okhttp 3.4.1, and okhttp 3.4.1 do not encode ;, so it make a query request like this

curl "http://127.0.0.1:8086/query?db=testdb&q=select%20*%20from%20notexist;select%20*%20from%20notexist"

there is a ; in the query string.
influxdb will return a response like this

{"results":[{}]}

sorry for my poor English.

    @Test
    public void testMultipleQuery() {
        String dbName = "unittest_" + System.currentTimeMillis();
        this.influxDB.createDatabase(dbName);
        QueryResult result = this.influxDB.query(new Query("SELECT * FROM not_exists;SELECT * FROM not_exists", dbName));
        Assert.assertEquals(2, result.getResults().size());
        this.influxDB.deleteDatabase(dbName);
    }

This unit test should fail!

@teixi
Copy link

teixi commented Nov 14, 2016

%3B decodes to ;
but ; also decodes to ;

The issue is that okhttp3 for browsers' consistency simply doesn't encode ; anymore.
square/okhttp#2975

Then InfluxDB backend in addition to the encoded %3B should also accept: ;
influxdata/influxdb#7623

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

No branches or pull requests

5 participants