Search Postgresql Archives

using column as 'mutex'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want to use a dbase record in Postgresql as a mutex in a garbage collection/file upload system.

If I tranfer an uploaded file to a directory, write all its meta information and file name in a record, the user should have 5 minutes to finish inputting the required info for the record. (I want to store in file system instead of database table).

So there will be two processes racing against each other in the database, the web page changing the status of the record to 'complete', and the cron job erasing files that have status 'in-process' and are older than ten minutes.

So there will probably be 6 possible scenarios:

1/ Web site changes status before the cron job gets to the record and deltes the file, no problem.
2/ Cron job changes the record and deletes the file before the website gets to the record, no problem.

3/ Both access the the record relatively at the same time, the web site having the earlier, lower transaction number and also finishes first.
4/ Both access the the record relatively at the same time, the cron job having the earlier, lower transaction number and also finishes first.

5/ Both access the the record relatively at the same time, the web site having the later, HIGHER transaction number BUT finishes first.
6/ Both access the the record relatively at the same time, the cron job having the later, HIGHER transaction number BUT finishes first.

Do I have the possiblities correctly described? What happens with cases 3-6?

Thanks in advance. I RTFMed and Googled, but did not see the answer.



Dennis Gearon

Signature Warning
----------------
EARTH has a Right To Life,
  otherwise we all die.

Read 'Hot, Flat, and Crowded'
Laugh at http://www.yert.com/film.php

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux