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

Cannot connect through mysql #28

Closed
simendsjo opened this issue May 1, 2012 · 12 comments
Closed

Cannot connect through mysql #28

simendsjo opened this issue May 1, 2012 · 12 comments

Comments

@simendsjo
Copy link
Contributor

It just hangs. I was able to connect before the library was integrated to vibe, so I guess the problem might be there.
I don't know vibe yet - anything in particular you want me to investigate?

writeln("connecting");
auto cn = new Connection("localhost", "user", "password", "vibetest");
writeln("connected");

(gdb) r
Starting program: /home/simendsjo/code/tmp/vibetest/app
[Thread debugging using libthread_db enabled]
[7FFFF7EC8F00:00000000 WRN] Failed to parse config file /etc/vibe/vibe.conf: /etc/vibe/vibe.conf: No such file or directory
[7FFFF7EC8F00:00000000 INF] Listening on 0.0.0.0 port 8080 succeeded
[7FFFF7EC8F00:00000000 ERR] Error binding listening socket
[7FFFF7EC8F00:00000000 INF] Listening on :: port 8080 failed
[7FFFF7EC8F00:00000000 INF] Running event loop...
connecting
^C
Program received signal SIGINT, Interrupt.
0x00007ffff6a29bd3 in __epoll_wait_nocancel () at ../sysdeps/unix/syscall-template.S:82
82 ../sysdeps/unix/syscall-template.S: No such file or directory.
in ../sysdeps/unix/syscall-template.S
(gdb) bt
#0 0x00007ffff6a29bd3 in __epoll_wait_nocancel () at ../sysdeps/unix/syscall-template.S:82
#1 0x00007ffff7bb98e7 in ?? () from /usr/lib/libevent-2.0.so.5
#2 0x00007ffff7ba4c44 in event_base_loop () from /usr/lib/libevent-2.0.so.5
#3 0x00000000004e9952 in vibe.core.drivers.libevent2.Libevent2Driver.runEventLoop() (this=0x7ffff7ecafc0)

at ../../vibe/vibe.d/bin/../source/vibe/core/drivers/libevent2.d:57

#4 0x00000000004ce530 in vibe.core.core.start() () at ../../vibe/vibe.d/bin/../source/vibe/core/core.d:42
#5 0x00000000004fbf64 in D main (args=...) at ../../vibe/vibe.d/bin/../source/vibe/appmain.d:38
#6 0x0000000000557b73 in rt.dmain2.main() ()
#7 0x0000000000822010 in ?? ()
#8 0x00007ffff7ecaf00 in ?? ()
#9 0x00007fffffffdf50 in ?? ()
#10 0x00007fffffffde20 in ?? ()
#11 0x00000000005574f3 in rt.dmain2.main() ()
#12 0x0000000000000001 in ?? ()
#13 0x0000000000000025 in ?? ()
#14 0x0000000000822020 in ?? ()
#15 0x00007fffffffdf50 in ?? ()
#16 0x00007fffffffdc60 in ?? ()
#17 0x0000000000000000 in ?? ()

@simendsjo
Copy link
Contributor Author

If I just wait a while, the following happens:
[7F902D382F00:00000000 INF] Running event loop...
connecting
[7F902D382F00:7F902D386C80 ERR] Error after page has been written: object.Exception@../../vibe/vibe.d/bin/../source/vibe/core/drivers/libevent2_tcp.d(271): Operating on closed TCPConnection.

/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(pure @safe bool std.exception.enforce!(bool, "../../vibe/vibe.d/bin/../source/vibe/core/drivers/libevent2_tcp.d", 271).enforce(bool, lazy const(char)[])+0x46) [0x4caf32]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.core.drivers.libevent2_tcp.Libevent2TcpConnection.checkConnected()+0x3a) [0x4ca2ca]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.core.drivers.libevent2_tcp.Libevent2TcpConnection.write(const(ubyte[]), bool)+0x4f) [0x4ca093]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.stream.stream.OutputStream.write(const(char[]), bool)+0x4d) [0x5388ed]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.http.server.HttpServerResponse.writeLine!(immutable(char)[], int, immutable(char)[]).writeLine(immutable(char)[], immutable(char)[], int, immutable(char)[])+0x7e) [0x53f2aa]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.http.server.HttpServerResponse.writeHeader()+0xa7) [0x53cccb]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(@Property vibe.stream.stream.OutputStream vibe.http.server.HttpServerResponse.bodyWriter()+0x205) [0x53c589]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void app.errorHandler(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse, vibe.http.server.HttpServerErrorInfo)+0x1d) [0x4c8451]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void std.functional.DelegateFaker!(void function(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse, vibe.http.server.HttpServerErrorInfo)).DelegateFaker.doIt(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse, vibe.http.server.HttpServerErrorInfo)+0x5d) [0x4c8825]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.http.server.handleHttpConnection(vibe.core.driver.TcpConnection, vibe.http.server.HTTPServerListener).void errorOut(int, immutable(char)[], immutable(char)[])+0xe6) [0x53e576]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.http.server.handleHttpConnection(vibe.core.driver.TcpConnection, vibe.http.server.HTTPServerListener)+0xf57) [0x53e20b]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.http.server.listenHttpPlain(vibe.http.server.HttpServerSettings, void delegate(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse)).void lambda19(vibe.core.driver.TcpConnection)+0x36) [0x53bac6]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(extern (C) void vibe.core.drivers.libevent2_tcp.onConnect(long, short, void
).void delegate() client_task(vibe.core.drivers.libevent2_tcp.TcpContext
, vibe.core.drivers.libevent2_tcp.TcpContext
).void __lambda1()+0xb3) [0x4ca957]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void vibe.core.core.runTask(void delegate()).void __lambda2()+0x36) [0x4ce70e]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(void core.thread.Fiber.run()+0x2a) [0x58382e]
/tmp/.rdmd-1000/home/simendsjo/code/tmp/vibetest/source/app.d.2A2600FC8A6DEC8A717A224A7D9CEB8E(fiber_entryPoint+0x5d) [0x5837b1]
[(nil)]
[7F902D382F00:7F902D386C80 WRN] Handling of connection failed: Operating on closed TCPConnection.

@simendsjo
Copy link
Contributor Author

_socket.read(_packet); in Connection.init_connection is where it fails

@dnadlinger
Copy link
Contributor

By the way, if you enclose your pastes in triple backticks, you'll get a monospace font and Markdown will leave the snipped alone.

@simendsjo
Copy link
Contributor Author

Hmm.. Is std.socket.receive just receiving until it receives 0 bytes, while your read() is trying to fetch buffer.length bytes?
If I change the buffer length to exactly the number of bytes retrieved (73 in my example), it works.
It works by changing to readAll() too, but this method uses both an internal buffer and an appender, which seems like a performance problem.

How about adding an overload to readAll to supply your own buffer or something like that?

@simendsjo
Copy link
Contributor Author

@klickverbot: Thanks, will do. I've been removing some --- lines and such to avoid the worst formatting issues :)

@simendsjo
Copy link
Contributor Author

Never mind what I said about the performance issues. Looks like the _packet.length is set to the actual length in other calls to read(). I'll create a pull.

@simendsjo
Copy link
Contributor Author

Nah, changing to readAll() hangs quite a while on while(!empty) in readAllDefault(). I think I need a method taking a buffer and just up to buffer.length bytes.

@s-ludwig
Copy link
Member

s-ludwig commented May 1, 2012

Yeah, I think both the original receive() and readAll() are quite hackish because they depend on the network and on the order of packets in the protocol. I have checked in an attempt to parse the real length of the packet. It seems to get further now but the connection is now closed by the server when the next getPacket() in Connection.open() is called. Probably it's necessary to go through the protocol and all places where receive() was called carfully to see if there are other occasions where receive() was expected to return partial data.

@s-ludwig
Copy link
Member

s-ludwig commented May 1, 2012

Btw. readAll() is supposed to read all data available on the connection until it is closed. So this is not really the right candidate (it is a bug if it returns earlier). The more or less equivalent behavior to receive() would be:

_packet.length = _socket.leastSize;
_socket.read(_packet);

@simendsjo
Copy link
Contributor Author

modules/mysql-native/source/mysql.d(1311): Error: == has no effect in expression (this._packet.length == (cast(InputStream)this._socket).leastSize())

@s-ludwig
Copy link
Member

s-ludwig commented May 1, 2012

Hm I'm not sure which line exactly that refers to but I have checked in another fix based on the leastSize method. I've also been able to partially test it and it seems to correctly fail with an auth failure for me.

@simendsjo
Copy link
Contributor Author

Thanks, it works now.

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

3 participants