

- Gdbm database as a semaphor update#
- Gdbm database as a semaphor full#
- Gdbm database as a semaphor code#

Gdbm database as a semaphor full#
Allows a full configuration of the serialization -> compression -> adapter stack using proxies (Similar to Rack middlewares).Supports a lot of backends with consistent behaviour (See below).Moneta provides a standard interface for interacting with various kinds of key/value stores. One record returned to any other thread attempting to get the record with locked = 'N'.Moneta: A unified interface for key/value stores Any other thread attempting to get the record with locked = 'N' gets no results.
Gdbm database as a semaphor update#
Update job_locker set locked = 'N', update_time = sysdate where job_name = 'myjob'
Gdbm database as a semaphor code#
You could have code to pull for that job name and locked = 'Y' and if still zero results, add the record. Any other thread attempting to get the record with locked = 'N' gets zero results. Any other thread attempting to get the record gets ORA-00054. Update job_locker set locked = 'Y', update_time = sysdate where job_name = 'myjob' Select * from job_locker where job_name='myjob' and locked = 'N' for update NOWAIT Insert into job_locker (job_name, locked) values ('myjob','N') Here are what might be some workable SQL commands, but no timeout except through a cron job hack: -ĬREATE TABLE "JOB_LOCKER" ( "JOB_NAME" VARCHAR2(128 BYTE), "LOCKED" VARCHAR2(1 BYTE), "UPDATE_TIME" TIMESTAMP (6) ) ĬREATE UNIQUE INDEX "JOB_LOCKER_PK" ON "JOB_LOCKER" ("JOB_NAME") ĪLTER TABLE "JOB_LOCKER" ADD CONSTRAINT "JOB_LOCKER_PK" PRIMARY KEY ("JOB_NAME") ĪLTER TABLE "JOB_LOCKER" MODIFY ("JOB_NAME" NOT NULL ENABLE) ĪLTER TABLE "JOB_LOCKER" MODIFY ("LOCKED" NOT NULL ENABLE) That would be a huge bonus to have a timeout! It would be cool, but I don't know if it's possible for a database-supported semaphore to have a time-out. Then at the end of my processing, I'd need to run another SQL transaction to release the semaphore. Years ago a developer that was a SQL wiz had a single SQL transaction that took the semaphore and returned true if it got it, and returned false if it didn't get it.

I could probably come-up with some workable SQL commands that used Oracle transaction processing, latches, or whatever, but I'd rather find something that's been tried and true. If several instances of the same code are running on different servers, I would like to use a database to make sure a process doesn't start on one server if it's already running on another server.
