IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15287


Ignore:
Timestamp:
Oct 11, 2007, 1:47:33 PM (19 years ago)
Author:
jhoblitt
Message:

resolve database deadlocks caused by subselcts on the table being inserted into

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pzgetimfiles.c

    r15159 r15287  
    261261    psFree(newImfiles);
    262262
    263     // queue the imfiles (files) in pzPendingImfile -- must be done before the
    264     // imfile is insterted into summitImfile (after that happens when don't
    265     // know which imfiles are new anymore (well thats not exactly true but it
    266     // make be someday if we have to beable to resync to modified datastore
    267     // entries)
    268     {
    269         char *query =
    270             "INSERT INTO pzPendingImfile"
     263    // queue the imfiles (files) dest. for pzPendingImfile in pending -- must
     264    // be done before the imfile is insterted into summitImfile (after that
     265    // happens when don't know which imfiles are new anymore (well thats not
     266    // exactly true but it may be someday if we have to beable to resync to
     267    // modified datastore entries)
     268    {
     269        char *query =
     270            "INSERT IGNORE INTO pzPendingImfile"
    271271            "   SElECT"
    272272            "       incoming.exp_name,"
     
    275275            "       incoming.class,"
    276276            "       incoming.class_id"
    277             "   FROM incoming"
    278             "   JOIN pzPendingExp"
    279             "       USING(exp_name, camera, telescope)"
    280             "   LEFT JOIN summitImfile"
    281             "       USING(exp_name, camera, telescope, class, class_id)"
    282             "   WHERE"
    283             "       summitImfile.exp_name is NULL"
    284             "       AND summitImfile.camera is NULL"
    285             "       AND summitImfile.telescope is NULL"
    286             "       AND summitImfile.class is NULL"
    287             "       AND summitImfile.class_id is NULL";
     277            "   FROM incoming";
    288278
    289279        if (!p_psDBRunQuery(config->dbh, query)) {
     
    297287    }
    298288
    299     if (!p_psDBRunQuery(config->dbh, "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED")) {
    300         // rollback
    301         if (!psDBRollback(config->dbh)) {
    302             psError(PS_ERR_UNKNOWN, false, "database error");
    303         }
    304         psError(PS_ERR_UNKNOWN, false, "database error");
    305         return false;
    306     }
    307 
    308289    // copy imfiles (files) from the temp table into summitImfiles
    309290    {
    310291        char *query =
    311             "INSERT INTO summitImfile"
     292            "INSERT IGNORE INTO summitImfile"
    312293            "   SElECT"
    313294            "       incoming.exp_name,"
     
    320301            "       incoming.class_id,"
    321302            "       incoming.uri"
    322             "   FROM incoming"
    323             "   LEFT JOIN summitImfile"
    324             "       USING(exp_name, camera, telescope, class, class_id)"
    325             "   WHERE"
    326             "       summitImfile.exp_name is NULL"
    327             "       AND summitImfile.camera is NULL"
    328             "       AND summitImfile.telescope is NULL"
    329             "       AND summitImfile.class is NULL"
    330             "       AND summitImfile.class_id is NULL";
    331 
     303            "   FROM incoming";
    332304        if (!p_psDBRunQuery(config->dbh, query)) {
    333305            // rollback
     
    353325            "   exp_name = '%s'"
    354326            "   AND camera = '%s'"
    355             "   AND telescope = '%s'";
     327            "   AND telescope = '%s'"
     328            "   AND imfiles IS NULL";
    356329        if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope, filesetid, camera, telescope)) {
    357330            // rollback
Note: See TracChangeset for help on using the changeset viewer.