Giter Club home page Giter Club logo

erlang_mysql's Introduction

This library was written by Magnus Ahltorp <[email protected]>.

My changes:
 * Commented out code for debug logging.
 * Updated/tweaked the build system.

erlang_mysql's People

Contributors

ngerakines avatar tritonrc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

erlang_mysql's Issues

Connect Error - Usage Error

First let me apologize for submitting this issue. I have to do something wrong, but I can't figure out what.

Cloning and building erlang_mysql works fine, but then I run into errors executing the tests:

$ make test
sh ebin/mysql.app.in 3
mkdir -p ebin
(cd src;make)
/Users/ck/lib/erlang/erlang_mysql/src
make[1]: Nothing to be done for `all'.
prove t/*.t
t/001-load..............ok                                                   
t/connect...............ok 1/0                                               
Crash dump was written to: erl_crash.dump
init terminating in do_boot (badarg)
t/connect...............dubious                                              
    Test returned status 1 (wstat 256, 0x100)
t/execute...............
Crash dump was written to: erl_crash.dump
init terminating in do_boot (badarg)
t/execute...............dubious                                              
    Test returned status 1 (wstat 256, 0x100)
t/fetch_many............
Crash dump was written to: erl_crash.dump
init terminating in do_boot (badarg)
t/fetch_many............dubious                                              
    Test returned status 1 (wstat 256, 0x100)
t/prepare...............
Crash dump was written to: erl_crash.dump
init terminating in do_boot (badarg)
t/prepare...............dubious                                              
    Test returned status 1 (wstat 256, 0x100)
t/prepare_concurrent....
Crash dump was written to: erl_crash.dump
init terminating in do_boot (badarg)
t/prepare_concurrent....dubious                                              
    Test returned status 1 (wstat 256, 0x100)
Failed Test            Stat Wstat Total Fail  List of Failed
-------------------------------------------------------------------------------
t/connect.t               1   256    ??   ??  ??
t/execute.t               1   256    ??   ??  ??
t/fetch_many.t            1   256    ??   ??  ??
t/prepare.t               1   256    ??   ??  ??
t/prepare_concurrent.t    1   256    ??   ??  ??
Failed 5/6 test scripts. -1/4 subtests failed.
Files=6, Tests=4,  4 wallclock secs ( 1.78 cusr +  2.41 csys =  4.19 CPU)
Failed 5/6 test programs. -1/4 subtests failed.
make: *** [test] Error 1

Then I check my existing code using the mysql drivers from http://erlang-mysql-driver.googlecode.com/svn/trunk to ensure everything is fine with MySQL. I'm able to connect to the database and retrieve rows. Replacing the mysql lib and the connect call with the one in erlang_mysql I again ran into the same error.

Any pointers where I went of the track are appreciated,

-ck

Prepared statements are not released

In the mysql_conn module, prepared statements are not being released properly and can result in an out-of-bounds error being raised by the mysql server.

Connection handling isn't so great.

There's a problem in the '... ! {remove_connection, Pid}' code when a connection is terminated. What can happen is that two spawned processes can both make requests to a connection for SQL executions whereby the first will fail and send a message back to the dispatcher to destroy and recreate the connection but only after the second one is to be executed. What needs to happen is that during the response phase for the mysql_dispatcher process, the timeout and connection destroy/recreate code needs to be handled at that point to not hang any subsequent connections.

Proof of concept:

> mysql:start_link/...
  -- connection is spawned
> spawn(fun() -> mysql:execute(foo, <<"select sleep(20);">>)) end)
  -- connection comes back without a timeout and does `whereis(mysql_dispatcher) ! {remove_connection, Pid}`
> spawn(fun() -> mysql:execute(foo, <<"select sleep(20);">>)) end)
  -- The message to remove the connection above is in the message inbox after this SQL execution request and this one fails, hangs, timesout.

This can be resolved fairly easily a few different ways. If one of you want to tackle it then let me know on Monday, otherwise I'll take a stab at it.

  • Kill the pid right there and immediately remove it from the connections list for that pool so the next sql executing fails immediately. Use a process monitor to catch that failure and init the reconnect phase.
  • On errors in the mysql_dispatcher pid, perform a remove connection and reconnect phase right there. Have it try once and send a message back to continue. It's the same thing as above but doesn't require a process monitor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.