On Wed, 1 Dec 2004, Alexander Jordanov wrote:
this is getting a bit of off thread so if anyone is annoyed please speak up.
I can't really make that because in PHP i can't set a global variable that
will be available for anyone that uses the script. If i set a variable and
change it in the script the next one that runs the script will have the
unchanged variable... I can't set a variable that will be valid across
users...
i meant global per-process.
I did the closest i could to what you wrote and need i say? the database got
locked again :( I checked all the scripts to be sure that every script uses
the class and there are no scripts that don't use the class... so 1) is
excluded can you explain more 2) i could't understand it right what do you
mean by :" fcntl based locks are process based so all thread 'get the lock'
" I don't know how exactly are working apache and PHP under Linux but i
suppose that the whole PHP is one process and every script is run as a
thread... so as a man opens the site a new thread is run for the script he
opened so yes the access is multythreaded as any web site.
what i mean is that if php threads are green threads and one of them gets
the
lock they all will have it. i've no idea how PHP, apache, and sqlite fit
together.
I also tried that:
database - seriously, if you coordinated ALL access through something like
ret = flock 'db.lock', LOCK_EX
mv '.db', 'db'
result = execute sql
mv 'db', '.db'
ret = flock 'db.lock', LOCK_UN
(or at least i tried to try it) but it seems that i can't rename the
database until the database is opened and it opens at the beggining of every
script and closes at the end so i can't rename the database in the middle of
the script because the database is opened and it doesn't let me.
o.k. - i'd still consider trying to do this somehow.
I added writing to file if the .lock file is locked but there is nothing in
the file so the .lock file is not locked and that means (at least i think
so) that the database shouldn't be locked by my script but by some other
process or am i wrong?
sounds right.
I tried not to commit a transaction but the database didn't lock... any
ideas?
I think it didn't lock because the PHP closes the database when the
script finishes and automatically commits.
again - i don't know about the specifics of PHP. it sounds like it's doing
too much though...
Today i asked from the hosting the access log lines that include my database
file but there was only the ftp process acesssing the file i thought that
the PHP also must be listed there as process but it wasn't there?? How is
that possible? Why isn't it there?
what ftp process? yours i assume. if you are refering to 'lsof' and
'fuser'
then these are would not appear - they use the /proc file system to show what
files are being used by a user but only while it's running.
Thank you I will wait more explanations on 2) but for now it seems to me
that it's 0) that is the most possible choice.
perhaps. i think you should post your problem to the PHP lists - it sounds
like this could be the problem.
one last thing you might consider: fcntl can tell you which pid is blocking
your lock (man fcntl). you could check which process is blocking your lock if
you ever get a 'database locked' error. having done that you could grab the
process information using
lines = `ps -elf | grep $pid`
and log this info. allow there is a small chance you'll miss the offending
process between the time the database is locked and when you try to find out
who has the lock using fcntl - this approach would tell you which (if any)
other process is grabbing your lock.
cheers.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================