Forum Moderators: coopster

Message Too Old, No Replies

Code running reliable

What all programmers fears :(

         

NomikOS

4:58 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



May be this is not 100% PHP stuff but I want programmers advise.

Ok. This is my constant stone inside of my shoe:

I code the best as I can -> that's under my control.
The server promise "99.9% uptime guaranteed" -> that's not under my control.

I mean... For example:
I count every (every) byte on accounts of my users. What if a script fails in middle of an edition session debt a fail on server? (100 Kb =/= 0 Kb)

I mean, it is possible or there is a routine or aspect or something to front this kind of matters.

What do you think abou it?

Please comment...
------------------------------

mcibor

5:13 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the risk of loosing some submited data for you? That's the main aspect!

Store the relevant info in db - it's seldom to crash even on server failure.

Moreover the server down is very rare, so to say the truth not that could be the problem, but the server-client connection (or client double clicking, etc)

I don't know if this will help you in any way, but to say the truth I still don't disturb myself with such thoughts :)

Michal Cibor

ergophobe

5:20 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, the obvious solution is to test any data that could be suspect. So, let's say you have

$y = 1000
$x =? some integer, 0 if no results, OR NULL if the db connection fails

Then you never want

$y = $x;

or
$y/$x

You want

if (isset($x)) // DB connection worked.
{
if (!$x) { echo "no results"; exit;}
}

Is that the sort of thing that you mean?

NomikOS

6:32 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



First, thank you very much for your support.

ergophobe:

With (100 Kb =/= 0 Kb) I mean than at finish of a script run, I want store 100 Kb (in a DB field called size) if submitted data is exactly 100 Kb and I don't want store 0 Kb (or NULL) debt a system failure.

Even a DB connection is working at start, not necessarily it is at finish.

mcibor:

Your words let me more comfortable, but, if we do accept than a crush is in our future (thanks Murphy again) then I want can manage it.

so...

Do you know if, for example, certain type of DB manage by self this type of matters:

Something like (on DB):
1) arrive a process to run -> (save request)
2) run process
2.a) all OK -> say OK to user
2.b) fail -> run it again 1,2,3 times or save request to run it when system will be up.

And not simply:
2.b) fail -> say: sorry for you (or even do not say nothing!)

...

ergophobe

5:50 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have this feeling that I'm not really thinking of the same sort of problem that you are, so I apologize if this response has nothing to do with the issues you are talking about.

As far as I understand what you're asking, any and no DB system can do what you want. In some systems the RDMS will automatically ensure data integrity if you use transactions and so forth. In older versions of MySQL without transactions, you have to handle rollbacks within your program logic which means that if the server goes down during the process, you might end up with corrupted data. If that's unacceptable, you would need to take additional measures.

In terms of reissuing the set of DB operations if it fails the first time, that is something a RDMS should not do, since it doesn't know what you want to do.

You as the programmer need to return error codes and decide what do on error.

NomikOS

7:04 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



Yes. This is presisely what I talking about it.

>> ... since it doesn't know what you want to do.
enlightenings words

I already have an eficient system of alerts for the end-user (inform, error, succsess, warning, fatal)

I will study about "transactions". Now I got it go. Thanks for your words.-

---

coopster

9:16 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could simulate the transactions as well, a lot of folks have done this before. Although, with todays database options you really shouldn't have to. Here is a relative thread that gives you some ideas ...

[webmasterworld.com...]

NomikOS

7:22 am on Nov 9, 2005 (gmt 0)

10+ Year Member



Yeah!
Definitely "Transactions" is my word of the week. I continue studying...

---

NomikOS

11:23 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



Through my enquiries i read in some places than:

.- innoDB goes to be the standard past MySQL 4.0. good!
.- oracle acquiries innoDB ...! will be continue GPL?

This discussion goes for a ride in database forum here performance == MyISAM v/s reliability == innoDB [webmasterworld.com], please visit for comments...

---

NomikOS

4:14 am on Nov 13, 2005 (gmt 0)

10+ Year Member



mcibor, ergophobe, coopster:
thank you very much. transactions is what i need.

this is the greatest.

i' ve work to do. you are the best.

---