Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-22375

ObjectStore.lockNotificationSequenceForUpdate is leaking query in case of error

    XMLWordPrintableJSON

Details

    Description

      In the ObjectStore.lockNotificationSequenceForUpdate method, the query doesn't get closed if an error occur:

        private void lockNotificationSequenceForUpdate() throws MetaException {
          if (sqlGenerator.getDbProduct() == DatabaseProduct.DERBY && directSql != null) {
            // Derby doesn't allow FOR UPDATE to lock the row being selected (See https://db.apache
            // .org/derby/docs/10.1/ref/rrefsqlj31783.html) . So lock the whole table. Since there's
            // only one row in the table, this shouldn't cause any performance degradation.
            new RetryingExecutor(conf, () -> {
              directSql.lockDbTable("NOTIFICATION_SEQUENCE");
            }).run();
          } else {
            String selectQuery = "select \"NEXT_EVENT_ID\" from \"NOTIFICATION_SEQUENCE\"";
            String lockingQuery = sqlGenerator.addForUpdateClause(selectQuery);
            new RetryingExecutor(conf, () -> {
              prepareQuotes();
              Query query = pm.newQuery("javax.jdo.query.SQL", lockingQuery);
              query.setUnique(true);
              // only need to execute it to get db Lock
              query.execute();
              query.closeAll();
            }).run();
          }
        }
      

      Attachments

        1. HIVE-22375.1.patch
          1 kB
          Marta Kuczora

        Activity

          People

            kuczoram Marta Kuczora
            kuczoram Marta Kuczora
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: