… | |
… | |
9 | DESCRIPTION |
9 | DESCRIPTION |
10 | (Note that in this manual, "thread" refers to real threads as |
10 | (Note that in this manual, "thread" refers to real threads as |
11 | implemented by the Coro module, not to the built-in windows process |
11 | implemented by the Coro module, not to the built-in windows process |
12 | emulation which unfortunately is also called "threads") |
12 | emulation which unfortunately is also called "threads") |
13 | |
13 | |
14 | This module "patches" DBD::mysql database handles so that they do not |
14 | This module replaces the I/O handlers for a database connection, with |
15 | block the whole process, but only the thread that they are used in. |
15 | the effect that "patched" database handles no longer block the all |
|
|
16 | threads of a process, but only the thread that does the request. |
16 | |
17 | |
17 | This can be used to make parallel sql requests using Coro, or to do |
18 | This can be used to make parallel sql requests using Coro, or to do |
18 | other stuff while mysql is rumbling in the background. |
19 | other stuff while mysql is rumbling in the background. |
19 | |
20 | |
20 | CAVEAT |
21 | CAVEAT |
21 | Note that this module must be linked against exactly the same (shared, |
22 | Note that this module must be linked against exactly the same (shared, |
22 | possibly not working with all OSes) libmysqlclient library as |
23 | possibly not working with all OSes) libmysqlclient library as |
23 | DBD::mysql, otherwise it will not work. |
24 | DBD::mysql, otherwise it will not work. |
24 | |
25 | |
|
|
26 | Also, this module requires a header file that apparently isn't installed |
|
|
27 | everywhere (violite.h), and therefore comes with it's own copy, which |
|
|
28 | might or might not be compatible to the violite.h of your library - when |
|
|
29 | in doubt, make sure all the libmysqlclient header files are installed |
|
|
30 | and delete the violite.h header that comes with this module. |
|
|
31 | |
|
|
32 | On the good side, this module does a multitude of checks to ensure that |
|
|
33 | the libray versions match on the binary level, so on incompatibilities |
|
|
34 | you should expect an exception when trying to unblock a handle, rather |
|
|
35 | than data corruption. |
|
|
36 | |
25 | Also, while this module makes database handles non-blocking, you still |
37 | Also, while this module makes database handles non-blocking, you still |
26 | cannot run multiple requests in parallel on the same database handle. If |
38 | cannot run multiple requests in parallel on the same database handle. If |
27 | you want to run multiple queries in parallel, you have to create |
39 | you want to run multiple queries in parallel, you have to create |
28 | multiple database connections, one for each thread that runs queries. |
40 | multiple database connections, one for each thread that runs queries. |
29 | Not doing so can corrupt your data - use a Coro::Semaphore when in |
41 | Not doing so can corrupt your data - use a Coro::Semaphore to protetc |
30 | doubt. |
42 | access to a shared database handle when in doubt. |
31 | |
43 | |
32 | If you make sure that you never run two or more requests in parallel, |
44 | If you make sure that you never run two or more requests in parallel, |
33 | you can freely share the database handles between threads, of course. |
45 | you can freely share the database handles between threads, of course. |
34 | |
|
|
35 | Also, this module uses a number of "unclean" techniques (patching an |
|
|
36 | internal libmysql structure for one thing) and was initially hacked |
|
|
37 | within a few hours on a long flight to Malaysia. |
|
|
38 | |
|
|
39 | It does, however, check whether it indeed got the structure layout |
|
|
40 | correct, so you should expect perl exceptions or early crashes as |
|
|
41 | opposed to data corruption when something goes wrong during patching. |
|
|
42 | |
46 | |
43 | SPEED |
47 | SPEED |
44 | This module is implemented in XS, and as long as mysqld replies quickly |
48 | This module is implemented in XS, and as long as mysqld replies quickly |
45 | enough, it adds no overhead to the standard libmysql communication |
49 | enough, it adds no overhead to the standard libmysql communication |
46 | routines (which are very badly written, btw.). In fact, since it has a |
50 | routines (which are very badly written, btw.). In fact, since it has a |
… | |
… | |
136 | } for 1..10; |
140 | } for 1..10; |
137 | |
141 | |
138 | SEE ALSO |
142 | SEE ALSO |
139 | Coro, PApp::SQL (a user friendly but efficient wrapper around DBI). |
143 | Coro, PApp::SQL (a user friendly but efficient wrapper around DBI). |
140 | |
144 | |
|
|
145 | HISTORY |
|
|
146 | This module was initially hacked together within a few hours on a long |
|
|
147 | flight to Malaysia, and seems to have worked ever since, with minor |
|
|
148 | adjustments for newer libmysqlclient libraries. |
|
|
149 | |
141 | AUTHOR |
150 | AUTHOR |
142 | Marc Lehmann <schmorp@schmorp.de> |
151 | Marc Lehmann <schmorp@schmorp.de> |
143 | http://home.schmorp.de/ |
152 | http://home.schmorp.de/ |
144 | |
153 | |