in reply to Using simultaneous threads
Running two threads performing concurrent accesses to a db via DBI is problematic. It might work for you, or it might not depending upon the design and implementation of the DBD::* driver and the vendor supplied API libraries/DLLs that it runs on top of. If they are not reentrant, or use (for example) the process-id of the calling app to coordinate access, then concurrent access from 2 or more threads of the same process can cause problems. I'm not sure about the reentrancy of the MySQL DBI/DBD/API chain.
However, if you are prepared to split the function above into 2, then you will be able to do most of what you want. The split is to run the first half of the code that queries DBs and theirs tables from the DBM in the man thread, and once you have a complete set of information, pass it into the threads (via a queue) and have them do the second half, of checking filesystem space and actually running the dump. The basic structure of the app would be as shown in Re: Question: Fast way to validate 600K websites. Substitute
If you only want two threads, only start two, but if your looking to maximise throughput, with IO bound tasks like these it is often as well to have at least two threads per CPU.
A question: Why are you reading the data in from the dump command just to write it straight out again having done nothing to it?
It would be quicker and simpler to just have mysqldump write it directly to a file. If it is just to count the bytes, then it would be easier to just query the size of the file once it has completed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using simultaneous threads
by mhearse (Chaplain) on May 13, 2008 at 15:27 UTC | |
by pc88mxer (Vicar) on May 13, 2008 at 16:32 UTC | |
by BrowserUk (Patriarch) on May 13, 2008 at 17:55 UTC | |
by mhearse (Chaplain) on May 14, 2008 at 06:16 UTC |