You are here: Re: concurrency, locks, multi-user app. « PHP Programming Language « IT news, forums, messages
Re: concurrency, locks, multi-user app.

Posted by Erwin Moller on 10/07/52 11:36

awebguynow wrote:

> I'm investigating this subject, particularly DB interactions, and could
> use input.
> It seems the dominant consensus, in these discussions is "use flock()
> ..."
> I guess this would be similar to, in Java terms, using synchronized
> (objLock) { ... }

True.

Problem with flock is however that W$-machines have no clue what you are
talking about. :-(

>
> This lends itself to OOP modularization, localization of reads and
> writes, using locks.
>
> Also, MySQL might say in the manual,
> this storage engine locks at the [page | row | ...] level.

Yes.

>
> But what does this get you ?
> If the goal is consistent data, and no simultaneous writes, its a
> worthy goal.

It means that mySQL will manage this for you where and when appropriate.
You do not have to worry about the details yourself, unless you want to
optimize (you can give mySQL hints), or want to lock some tables/rows for
some other reason.

In general: Just trust your database engine to do its job right.

> But how should the application be designed ?

Well...
How can we answer such a question?

Some shots in the dark:

If you are doing webstuff: Just include a connection-file above every script
that gives you a valid connection to the datatabase.
Use this connection in your script for select/update/delete/etc.

I am unsure if mySQL understands transactions.
If you want a better database, switch to Postgresql: it is a lot more
mature.

> Do you limit access to reports, displays, forms on data that is
> currently being written ?

Most database engines have a maximum number of connections, if that is what
you mean. Ofter 32 or 64. But that number can easily be modified by some
ini-file.

> If a PHP flock() or DB lock impedes access, what then ?

flock and database row/table lock are two different things. They share the
word 'lock' but that is about it.
But for both goes that the script that trying it waits and tries again.
Maybe they use some fancy sheduling behing the scenes (like monitor
functionality found in Java), but I am unsure about the how and when.

> Does it wait a time slice then try ? or throw error ? fatal error ?
> recover ?

For flock: just try it yourself.
Make 1 script that flocks a file.
Make another that tries this too.

>
> Any good articles, references ? any from Wrox, O'Reilly ? TIA for
> responses

www.php.net is a good resource. Be sure to read all usercontributions too.
They help a lot understanding what is going on.

Hope this helped you a bit.

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация