87e42c2812e7a93ff6c52ae5148505373d7e0c6d galt Wed Aug 30 15:15:14 2017 -0700 Added advisory lock to cdwMakeFileTags so two users cannot run it at exactly the same time. If somebody else is running it, it aborts with a message explaining the conflict. Multiple users should not be running this at the same time, or it can corrupt the cdwFileTags table build. diff --git src/hg/inc/jksql.h src/hg/inc/jksql.h index 20b60da..6299dca 100644 --- src/hg/inc/jksql.h +++ src/hg/inc/jksql.h @@ -345,34 +345,40 @@ * Do a slFreeList on result when done. */ struct slPair *sqlQuickPairList(struct sqlConnection *conn, char *query); /* Return a list of slPairs with the results of a two-column query. * Free result with slPairFreeValsAndList. */ void sqlRenameTable(struct sqlConnection *sc, char *table1, char *table2); /* Rename table */ void sqlCopyTable(struct sqlConnection *sc, char *table1, char *table2); /* Copy table1 to table2 */ void sqlDropTable(struct sqlConnection *sc, char *table); /* Drop table if it exists. */ +void sqlGetLockWithTimeout(struct sqlConnection *sc, char *name, int wait); +/* Tries to get an advisory lock on the process, waiting for wait seconds. */ +/* Blocks another client from obtaining a lock with the same name. */ + void sqlGetLock(struct sqlConnection *sc, char *name); -/* Sets an advisory lock on the process for 1000s returns 1 if successful,*/ -/* 0 if name already locked or NULL if error occurred */ -/* blocks another client from obtaining a lock with the same name */ +/* Gets an advisory lock created by GET_LOCK in sqlGetLock. Waits up to 1000 seconds. */ + +boolean sqlIsLocked(struct sqlConnection *sc, char *name); +/* Tests if an advisory lock on the given name has been set. + * Returns true if lock has been set, otherwise returns false. */ void sqlReleaseLock(struct sqlConnection *sc, char *name); /* Releases an advisory lock created by GET_LOCK in sqlGetLock */ void sqlHardLockTables(struct sqlConnection *sc, struct slName *tableList, boolean isWrite); /* Hard lock given table list. Unlock with sqlHardUnlockAll. */ void sqlHardLockTable(struct sqlConnection *sc, char *table, boolean isWrite); /* Lock a single table. Unlock with sqlHardUnlockAll. */ void sqlHardLockAll(struct sqlConnection *sc, boolean isWrite); /* Lock all tables in current database. Unlock with sqlHardUnlockAll. */ void sqlHardUnlockAll(struct sqlConnection *sc);