mauricio / postgresql-async

Async, Netty based, database drivers for PostgreSQL and MySQL written in Scala
Apache License 2.0
1.43k stars 222 forks source link

Console warnings in "hello world" app. #68

Open hsyed opened 10 years ago

hsyed commented 10 years ago

Decided to give the driver a go. But getting warnings. There is a bazillion of these warnings when some actors go down in an akka app, and they show up in this hello world chunk of code as well.

Test extends App {
    println("starting")
    val configuration = URLParser.parse("jdbc:postgresql://localhost/crawler?user=hassan&password=")
    val connection = new PostgreSQLConnection(configuration)
    Await.result(connection.connect, 5.seconds)

    println("connect")

    val fut =  connection.sendQuery("select 229;")
    val actualResult = Await.result(fut,5 seconds)

    println(actualResult.rows.map(_.head).map(_.apply(0)).get)

    val res = Await.result(connection.disconnect,5.seconds)
    println("disconnect")
    Thread.sleep(5000)
}

Warning :

18:59:21.236 [pool-6-thread-1] WARN  io.netty.channel.nio.NioEventLoop - Selector.select() returned prematurely 512 times in a row; rebuilding selector.
18:59:21.236 [pool-6-thread-1] INFO  io.netty.channel.nio.NioEventLoop - Migrated 0 channel(s) to the new Selector.
[success] Total time: 10 s, completed 08-Dec-2013 18:59:21
18:59:21.242 [pool-6-thread-1] WARN  io.netty.channel.nio.NioEventLoop - Selector.select() returned prematurely 512 times in a row; rebuilding selector.
18:59:21.242 [pool-6-thread-1] INFO  io.netty.channel.nio.NioEventLoop - Migrated 0 channel(s) to the new Selector.
mauricio commented 10 years ago

It's an NIO bug that netty works around, it's just letting you know that it has happened.

ryanlecompte commented 10 years ago

Do you suggest just adjusting the log level for that?

On Dec 8, 2013, at 12:14 PM, Maurício Linhares notifications@github.com wrote:

It's an NIO bug that netty works around, it's just letting you know that it has happened.

— Reply to this email directly or view it on GitHub.

mauricio commented 10 years ago

Is it causing a lot of noise?

I wouldn't do it.

I have it set to debug for the project builds and I don't really see any of that -> https://travis-ci.org/mauricio/postgresql-async/builds/15141939

hsyed commented 10 years ago

Bear in mind that I do not have much experience with this library yet. But, Now that I put a wait on the disconnect and clean up properly it's not a lot of noise. Just 2-3 message pairs per connection close.

However, it was an endless loop when an actor didn't clean up properly. This could explode a log file in a system with a badly written actor. I'd rather have the vm crash than terrorise the log file :D

It is still a very disconcerting message for someone starting with async coding in Java. A low level ASIO event loop failing 512 times in a method called "select" screams "run away" to me. Do you know what is going on underneath ? I would suggest rewriting the error message and make it less dangerous looking :D

mauricio commented 10 years ago

How would you rewrite it?

That's inside Netty itself, not the driver.

Em domingo, 8 de dezembro de 2013, hsyed escreveu:

Bear in mind that I do not have much experience with this library yet. But, Now that I put a wait on the disconnect and clean up properly it's not a lot of noise. Just 2-3 message pairs per connection close.

It is still a very disconcerting message for someone starting with async coding in Java. A low level ASIO event loop failing 512 times in a method called "select" screams "run away" to me. Do you know what is going on underneath ? I might rewrite the error message and make it less dangerous looking :D

— Reply to this email directly or view it on GitHubhttps://github.com/mauricio/postgresql-async/issues/68#issuecomment-30097013 .

Maurício Linhares http://mauricio.github.io/ - http://twitter.com/#!/mauriciojr

normanmaurer commented 10 years ago

@mauricio on a disconnect you close also the EventLoopGroup ?

mauricio commented 10 years ago

@normanmaurer no, there's a single event loop that is kept for all connections as a static variable. Should I create one event loop for every connection?

mauricio commented 10 years ago

@hsyed @ryanlecompte can you guys provide more details about your environment? OS, Kernel, JVM and DB versions?

hsyed commented 10 years ago

Sorry for the delay.

OS X 10.9.1. Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_45), postgres 9.3.2

mauricio commented 10 years ago

@hsyed do you see this same issue when you run the project tests?

ryanlecompte commented 10 years ago

I've only seen this issue when running using sbt's run-main. If I bundle up a jar and execute that (totally outside of sbt), everything works just fine.

On Mon, Dec 23, 2013 at 12:35 PM, Maurício Linhares < notifications@github.com> wrote:

@hsyed https://github.com/hsyed do you see this same issue when you run the project tests?

— Reply to this email directly or view it on GitHubhttps://github.com/mauricio/postgresql-async/issues/68#issuecomment-31142325 .

mauricio commented 10 years ago

@ryanlecompte can you create a small GH repo with the code you're seeing this?

ryanlecompte commented 10 years ago

I can't right now - about to take off for the holidays! Hopefully @hsyed can, though. It's really just creating a basic connection pool, execute a simple query, then call close()/disconnect() (can't remember name of method exactly). Right after closing, the logging goes crazy for about 6 seconds and then the program finally exits. This is with postgresql, not mysql.

On Mon, Dec 23, 2013 at 12:37 PM, Maurício Linhares < notifications@github.com> wrote:

@ryanlecompte https://github.com/ryanlecompte can you create a small GH repo with the code you're seeing this?

— Reply to this email directly or view it on GitHubhttps://github.com/mauricio/postgresql-async/issues/68#issuecomment-31142464 .