Hi,
I have a script which inserts some rows in an InnoDB table.
I want to be sure that all the rows are inserted, so i use a mysql
transaction ("start transaction", insertions, and "commit").
Problem is that i also want to avoid a timeout (about 60 000 lines are
concerned and InnoDB tables are much slower than MyISAM ones) and i cut
that process in x reloads of the script.
Let's say for the example my script can insert 10 lines each time it
runs and that i have to insert 15 lines only.
1) the script runs, i guess the "log" of the transaction contains my ten
first lines.
2) the script reloads itself and stop after the last 5 lines (it started
with the 11th line).
3) Guess what i have in my table ?
4) the last 5 lines : the transaction forgot my ten first lines...
I know the mysql connection is lost at the end of the first execution of
the script, but how can i manage this to avoid this loss of data ?
I read in http://www.php.net/manual/en/feature...onnections.php that a
persistent connection to mysql wasn't the solution, so i don't see today
how handle such a mysql transaction through my x reloads of the script.
The website runs PHP Version 4.3.4 and MySQL version 4.0.16.
Any ideas ?
thanks,
Arnaud 15 3186
Wait. Doesn't the PHP manual give you the solution you're looking for?
"... is that when using transactions, a transaction block will also carry
over to the next script which uses that connection if script execution ends
before the transaction block does..."
Uzytkownik "Arnaud" <no_email@no_email_email_no.org> napisal w wiadomosci
news:40***********************@news.free.fr... Hi, I have a script which inserts some rows in an InnoDB table. I want to be sure that all the rows are inserted, so i use a mysql transaction ("start transaction", insertions, and "commit").
Problem is that i also want to avoid a timeout (about 60 000 lines are concerned and InnoDB tables are much slower than MyISAM ones) and i cut that process in x reloads of the script.
Let's say for the example my script can insert 10 lines each time it runs and that i have to insert 15 lines only. 1) the script runs, i guess the "log" of the transaction contains my ten first lines. 2) the script reloads itself and stop after the last 5 lines (it started with the 11th line). 3) Guess what i have in my table ? 4) the last 5 lines : the transaction forgot my ten first lines...
I know the mysql connection is lost at the end of the first execution of the script, but how can i manage this to avoid this loss of data ? I read in http://www.php.net/manual/en/feature...onnections.php that a persistent connection to mysql wasn't the solution, so i don't see today how handle such a mysql transaction through my x reloads of the script. The website runs PHP Version 4.3.4 and MySQL version 4.0.16.
Any ideas ? thanks, Arnaud
"Chung Leong" <ch***********@hotmail.com> a écrit dans le message de
news:IJ********************@comcast.com... Wait. Doesn't the PHP manual give you the solution you're looking for?
"... is that when using transactions, a transaction block will also carry over to the next script which uses that connection if script execution
ends before the transaction block does..."
Well you're right, i missed that but i think it concerns the persistent
connection method and i can read at the beginning of the link i gave, about
this kind of connection :
"they do not give you an ability to build up a transaction efficiently".
So you think the only way for me to resolve my problem is to use one of
these persistent connection and call register_shutdown_function() to unlock
or rollback if a problem occured ?
bye,
Arnaud
Arnaud: Hi, I have a script which inserts some rows in an InnoDB table. I want to be sure that all the rows are inserted, so i use a mysql transaction ("start transaction", insertions, and "commit").
Problem is that i also want to avoid a timeout (about 60 000 lines are concerned and InnoDB tables are much slower than MyISAM ones) and i cut that process in x reloads of the script.
Can't you just extend the timeout? http://www.php.net/manual/en/functio...time-limit.php
André Næss
You would probably need to see the number of persistent connections to 1, in
order to guarantee that you get the same connection with consecutive
requests. Maybe that's the inefficiency the manual refers to.
For time consuming tasks like yours, most people would just spawn a new
instance of PHP and do everything in a single shot.
Uzytkownik "Arnaud" <no_email@email_no_no_email.org> napisal w wiadomosci
news:40***********************@news.free.fr... "Chung Leong" <ch***********@hotmail.com> a écrit dans le message de news:IJ********************@comcast.com... Wait. Doesn't the PHP manual give you the solution you're looking for?
"... is that when using transactions, a transaction block will also
carry over to the next script which uses that connection if script execution ends before the transaction block does..."
Well you're right, i missed that but i think it concerns the persistent connection method and i can read at the beginning of the link i gave,
about this kind of connection : "they do not give you an ability to build up a transaction efficiently".
So you think the only way for me to resolve my problem is to use one of these persistent connection and call register_shutdown_function() to
unlock or rollback if a problem occured ?
bye, Arnaud
"André Næss" <an*********************@ifi.uio.no> a écrit dans le message de
news:bv**********@maud.ifi.uio.no... Can't you just extend the timeout? http://www.php.net/manual/en/functio...time-limit.php
Hi,
Nice try but it's a safe-mode shared server, so i can't :(
So there is no way to run a transaction inside a script reload ?
Arnaud
On Mon, 26 Jan 2004 00:00:50 -0500, "Chung Leong" <ch***********@hotmail.com>
wrote: I have a script which inserts some rows in an InnoDB table. I want to be sure that all the rows are inserted, so i use a mysql transaction ("start transaction", insertions, and "commit").
Problem is that i also want to avoid a timeout (about 60 000 lines are concerned and InnoDB tables are much slower than MyISAM ones) and i cut that process in x reloads of the script.
Wait. Doesn't the PHP manual give you the solution you're looking for?
"... is that when using transactions, a transaction block will also carry over to the next script which uses that connection if script execution ends before the transaction block does..."
That's a warning that there are nasty consequences if you try to span
transactions over multiple requests. You're not in any way guaranteed to get
the same MySQL session on the next page, so you can't continue the transaction.
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
"Andy Hassall" <an**@andyh.co.uk> a écrit dans le message de
news:3g********************************@4ax.com That's a warning that there are nasty consequences if you try to span transactions over multiple requests. You're not in any way guaranteed to
get the same MySQL session on the next page, so you can't continue the
transaction.
So an idea to resolve that problem ?
thanks,
Arnaud
Arnaud: Hi, I have a script which inserts some rows in an InnoDB table. I want to be sure that all the rows are inserted, so i use a mysql transaction ("start transaction", insertions, and "commit").
Problem is that i also want to avoid a timeout (about 60 000 lines are concerned and InnoDB tables are much slower than MyISAM ones) and i cut that process in x reloads of the script.
Generate a SQL file with the SQL necessary for performing this mass insert
and process the SQL file with the MySQL command line tool.
André Næss
Hi! "Andy Hassall" <an**@andyh.co.uk> a écrit dans le message de news:3g********************************@4ax.com That's a warning that there are nasty consequences if you try to span transactions over multiple requests. You're not in any way guaranteed to get the same MySQL session on the next page, so you can't continue the transaction.
So an idea to resolve that problem ? thanks,
Release the transaction with register_unload_function(). However, I
wouldn't trust such a mechanism too much, because a database lock at
2am means 6 hours downtime still.
Instead, implement your transactions on the client side
HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces. http://sourceforge.net/projects/phpdbedittk/
"Chung Leong" <ch***********@hotmail.com> a écrit dans le message de
news:yr********************@comcast.com... You would probably need to see the number of persistent connections to 1,
in order to guarantee that you get the same connection with consecutive requests. Maybe that's the inefficiency the manual refers to.
I'll try.
For time consuming tasks like yours, most people would just spawn a new instance of PHP and do everything in a single shot.
I'm on a shared server, i don't think i can do that.
Thanks,
Arnaud
"Jochen Daum" <jo*********@cans.co.nz> a écrit dans le message de
news:7h********************************@4ax.com... Release the transaction with register_unload_function(). However, I wouldn't trust such a mechanism too much, because a database lock at 2am means 6 hours downtime still.
I don't see this function anywhere ?
Instead, implement your transactions on the client side
What do you mean ?
I'm trying to construct a script which allow some end user guy to update a
database, i don't want them to run a mysql command or things like that...
bye,
Arnaud
"André Næss" <an*********************@ifi.uio.no> a écrit dans le message de
news:bv**********@maud.ifi.uio.no... Generate a SQL file with the SQL necessary for performing this mass insert and process the SQL file with the MySQL command line tool.
So i have to create a batch or something, because i don't want the end user
to use the mysql command line tool, moreover the php scripts are hosted on a
shared server and the end users can't access to the mysql command line tool
i guess...
Thanks for the suggestion anyway,
Arnaud
Hi Arnaud!
On Wed, 28 Jan 2004 08:27:09 +0100, "Arnaud"
<no_email@email_no_no_email.org> wrote: Release the transaction with register_unload_function(). However, I wouldn't trust such a mechanism too much, because a database lock at 2am means 6 hours downtime still. I don't see this function anywhere ?
Sorry, mixed it up, its register_shutdown_function() Instead, implement your transactions on the client side What do you mean ? I'm trying to construct a script which allow some end user guy to update a database, i don't want them to run a mysql command or things like that...
I meant writing php side software, that is able to do the same as a
transaction, ie. running it atomic (all or nothing) and all the other
stuff you need.
HTH, Jochen bye, Arnaud
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces. http://sourceforge.net/projects/phpdbedittk/
"Jochen Daum" <jo*********@cans.co.nz> a écrit dans le message de What do you mean ? I'm trying to construct a script which allow some end user guy to update
adatabase, i don't want them to run a mysql command or things like that...
I meant writing php side software, that is able to do the same as a transaction, ie. running it atomic (all or nothing) and all the other stuff you need.
Hi Jochen,
ok that's clearer, thanks for your help.
Bye,
Arnaud
Arnaud: "André Næss" <an*********************@ifi.uio.no> a écrit dans le message de news:bv**********@maud.ifi.uio.no... Generate a SQL file with the SQL necessary for performing this mass insert and process the SQL file with the MySQL command line tool.
So i have to create a batch or something, because i don't want the end user to use the mysql command line tool, moreover the php scripts are hosted on a shared server and the end users can't access to the mysql command line tool i guess...
Now I'm curious, what sort of data are we talking about here? Because the
user can't be punching values yielding an insert of 60,000 lines? How does
the user submit the data?
André Næss This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Feller |
last post by:
What are best practices to check to see if a .php script is called for the
first time versus a user hitting a refresh button on their browser?
I am playing around with a PHP front-end to a...
|
by: Roel |
last post by:
Hello,
I have a simple script that will reload http://website/CAM1picture.jpg every
xx minutes. I'm trying to add a form <input type="submit" value="CAM1"
name="B1"><input type="submit"...
|
by: Ola Fjelddahl |
last post by:
hi.
I load a script dynamically and it works
* everytime with IE6.
* sometimes! with Mozilla1.5 <- makes me curious
* never with Opera7.11
all tests on WindowsXP.
With "sometimes" I mean
|
by: Robin Tucker |
last post by:
I have a query batch "update" script that upgrades my users database from,
say version 0 to version 1, or from version 1 to version 2. I would like to
know how I can wrap the entire script in a...
|
by: Abdul-Wahid Paterson |
last post by:
Hi,
I have had a site working for the last 2 years and have had no problems
until at the weekend I replace my database server with a newer one. The
database migration went like a dream and I had...
|
by: rich |
last post by:
I am building an app using php and postgresql. My questionis this.
How do you handle people wanting to make parallel changes to a record.
Since in web apps you are doing a select, bring over a...
|
by: Kurt |
last post by:
Hello
I have questions about how works transaction log et the database
tempdb in SQL Server and I hop you could help me
- Is it possible to reduce the size of the transaction log fil during
an...
|
by: Ben |
last post by:
Hi!
I have a trigger created for Customer table. My front-end is access. What
is the best approach to handle a trigger result when adding a new customer
record?
Below is the trigger script:...
|
by: psycho |
last post by:
I am working on an N-tier application using following components:
1. Data Access Layer using DLINQ which consists of Data Context class
and Table Mapping classes.
2. Business Logic Layer....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |