windows is not supported #7

royaltm opened this Issue May 8, 2012 · 10 comments


None yet
2 participants

royaltm commented May 8, 2012

Windows is not supported due to the fact, that PG::Connection#socket returns not a valid ruby file descriptor on Windows.

It would need some extra WSADuplicateSocket trickery to get it working.

PG::Connection#socket_io does work on Windows since ruby-pg version 0.15.0, but requires at least Ruby-2.0.0.


royaltm commented Aug 31, 2013

thanks for hint, I'll check it


royaltm commented Sep 2, 2013

The problem is, that pg >= 0.15.0 has broken autoreconnect feature of PG::EM::Client.
I'm receiving strange GVL ruby errors when connection is closed due to the server shutdown and not even on windows.
Need further investigation and probably the Watcher module will need some serious re-work.

The problem is, that pg >= 0.15.0 has broken autoreconnect feature of

It shouldn't. Can you post a sample how to reproduce the GVL errors?


royaltm commented Sep 3, 2013

I've just run EM::PG::Client auto re-connect tests with the newer pg.

make sure you have sudo access to postgres (to be able to start/stop postgres server)
tests also assume you may:
sudo su - postgres

and postgres is your postmaster user

you may change it here and here

export PGDATA=path/to/your/pg/data

$ gem install pg --version 0.16.1 (or 0.15.1)
$ git reset v0.2.1 --hard
$ rake test[unsafe]
WARNING: The test needs to be run with an available local PostgreSQL server
{"PGDATABASE"=>"test", "PGHOST"=>"/tmp"} rspec spec/em_client_autoreconnect.rb

em-pg default autoreconnect
  should not have modified argument Hash
  should get database size using query
waiting for server to shut down.... done
server stopped
waiting for server to start.... done
server started
(eval):4: [BUG] rb_thread_call_with_gvl: called by a thread which has GVL.
ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0045 p:---- s:0167 b:0167 l:000166 d:000166 CFUNC  :send_query

full stack-trace here

The PG::Connection#send_query is called just after the server restart and connected via unix sockets.
In pg <= 0.14 in such a case #send_query raised PG::Error immediately so I could check connection status.
Since pg 0.15 it just throws up the above.


royaltm commented Sep 3, 2013

This happens only for UNIX SOCKET connection. With TCP/IP everything is fine and probably due to the fact that the error is not raised in #send_query method.
Just comment out this line to skip unix socket tests.


royaltm commented Sep 3, 2013

Ok, it seems I've finally created minimal BUG reproduction example:

#11 (comment)


royaltm commented Dec 29, 2013

Seems that em-pg-client 0.3 fixes it - all specs (except auto re-connect tests, I need more time to install postgres on windows, etc.) are passing at least on ruby2.0.0p353 i386-mingw32.


royaltm commented Dec 30, 2013

Looks like problem solved. All current specs are passing on windows.

royaltm closed this Dec 31, 2013

The specs of 0.3.0 pass for me too on ruby2.0.0p353 i386-mingw32. Really great work!

I don't use em-pg-client by myself, but we try to fully support these use cases. So if you have any issues or see things that are worth to merge to ruby-pg, don't hesitate to contact us through the mailing list or the issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment