implydata / plyql

MySQL-like queries for Druid built on top of Plywood

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mysql gateway closing connection issue

rajitha703 opened this issue · comments

Hi,

Trying to access Mysql gateway using jdbc driver from java gives error saying connection closed at the end.

New connection 7
[7] Got SQL: SELECT @@session.autocommit
[7] Got SQL: SET NAMES utf8mb4
[7] Got SQL: SET character_set_results = NULL
[7] Got SQL: SET autocommit=1
[7] Got SQL: select page , sum( count ) as cnt from wikiticker where (( __time >= '2015-03-12T00:00:00' ) and ( __time < '2016-09-13T00:00:00' )) group by page order by cnt asc limit 5;
[7] Error: Connection lost: The server closed the connection.

The java client code I used is as follows :
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3307/plyql1");
stmt = con.createStatement();
rs = stmt.executeQuery(
" SELECT page, SUM(count) AS Edits FROM wikiticker WHERE '2015-09-12T00:00:00' <= __time AND __time < '2015-09-13T00:00:00' GROUP BY page ORDER BY Edits DESC LIMIT 5;"
);

  while (rs.next()) {
    String page = rs.getString("page");
    long count = rs.getLong("Edits");
    System.out.println(String.format("page[%s] count[%d]", page, count));
  }
} catch (SQLException | ClassNotFoundException s) {
  s.printStackTrace();
}

Hi what, mysql-connector-java version are you using? I can not repo this on the few versions I tried.

Hi @vogievetsky ,
I am using mysql-connector- java version : 6.0.2

I am looking into this but failing to reproduce at the moment.
I am also a little confused as to your logs:

In your proxy log it shows:

Got SQL: select page , sum( count ) as cnt from wikiticker where (( __time >= '2015-03-12T00:00:00' ) and ( __time < '2016-09-13T00:00:00' )) group by page order by cnt asc limit 5;

Yet in your code you have:

" SELECT page, SUM(count) AS Edits FROM wikiticker WHERE '2015-09-12T00:00:00' <= __time AND __time < '2015-09-13T00:00:00' GROUP BY page ORDER BY Edits DESC LIMIT 5;"

Those do not match up, those are similar but different queries. Could you please check that you grabbed the correct query for the proxy log?

Hi @rajitha703 I just made some fixes for #29 that might have been affecting you (I am not sure) can you please try again?

Hi @vogievetsky ,

That's a typo from my end. I rechecked it again and the issue still exists. I receive the data but the mysql console gives Error: Connection lost: The server closed the connection. . This can be seen even in issue #29. Connection seems to be deliberately closed here with a error message.

However, I am trying to get the new plyql code up on my box this way. But I get this error :
rajitha@IM0318-L0:~/Downloads/plyql-master$ bin/plyql -h localhost:8082 -i P2Y --experimental-mysql-gateway 3307
module.js:341
throw err;
^
Error: Cannot find module '/home/rajitha/Downloads/plyql-master/build/cli'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object. (/home/rajitha/Downloads/plyql-master/bin/plyql:7:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)

Before this, I had pulled Imply latest code and from there could bring the mysql gateway up, but not really sure how to get the latest code of just plyql running on my box. Can you please help me here so that I can always update the latest changes of Plyql in my local? Thanks.

Sure thing, the plyql you download form master needs to be compiled. which is why you are not finding build/cli.

I assume you are on a mac:

  1. make sure you have node installed (type in node --version) it should print version 4 or above
    (if you do not, the easiest way to install node is with homebrew: brew update; brew install node
  2. use npm to install plyql like so: npm install -g plyql then the plyql command should become available to you. Try plyql --version

Hi @vogievetsky ,

I use Ubuntu. I downloaded the latest code of plyql and did the following:

rajitha@IM0318-L0:~/plyql$ sudo npm install -g plyql
/usr/bin/plyql -> /usr/lib/node_modules/plyql/bin/plyql
/usr/lib
`-- plyql@0.7.13


However when I check the version , I don't see it updated.

rajitha@IM0318-L0:~/plyql$ plyql --version
plyql version 0.5.4 [beta](plywood version 0.7.19)

Also when I try to start the gateway from the plyql directory, I find this :
rajitha@IM0318-L0:~/plyql$ bin/plyql -h localhost:8082 -i P2Y --experimental-mysql-gateway 3307
module.js:341
throw err;
^

Error: Cannot find module '/home/rajitha/plyql/build/cli'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)

Can you please let me know what I am missing here. Thanks.

Hi @vogievetsky ,

Can you please help me here? I m badly stuck.
I am using Imply for bringing up the Mysql gateway of Plyql and it still is pointing to an older version.
http://imply.io/docs/latest/release

The command "bin/plyql -h localhost:8082 -i P2Y --experimental-mysql-gateway 3307" seems to only work from IMPLY directory and not PLYQL.

I am not still sure how to upgrade plyql separately and bring up the mysql gateway..Please help :(

Hi @vogievetsky , I had some older version of plyql being referred . Removed it and now it works. Thanks for checking on this. :)

Awesome!

Hi there,

I'm still having the exact same issue described in this post, and I'm using the latest version includid in Imply, the PlyQL 0.7.6

Could you pleas help me?

Thanks

I istalled the plyql 0.8.2 and still the same... May it's better not to use the imply bundle and install everything standalone?