Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
How to stop gracefully a long running transaction in Hana DB

I am using a hana-client tool from https://www.npmjs.com/package/@sap/hana-client Essentially I have a callback that takes long time so I decide to run it in parallel in Promise.race to throw an Error after 1000 ms(Timeout in async/await)

This won't break the currently running operation in callback, but I hoped that rollback will terminate it once the catch block is reached after 1000 ms. This rollback doesn't seem to work though and it just waits until the callback will be completed. This blocks a table in my DB for quite some time.

My next idea was to use db.abort() from https://help.sap.com/viewer/f1b440ded6144a54ada97ff95dac7adf/2.12/en-US/b98b880fc6a344aa85ef0b471fa19af4.html However this also does not seem to break the long taking callback. Am I doing something wrong?

   try {
      db = await this.acquire();
      db.connection.setAutoCommit(false);
      const wrapper = new HanaClientAsyncWrapper(db);
      await Promise.race([
        callback(wrapper),
        new Promise((_, reject) => setTimeout(
          async () => {
            reject(new Error("Timeout due to a long-running operation"));
            // await db.abort(); <- does not work
          }, 1000,
        )),
      ]);
      await db.commit();
    } catch (err) {
      if (db) {
        await db.rollback();
      }
      throw err;
    } finally {
      if (db) {
        db.connection.setAutoCommit(true);
        await this.release(db);
      }
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Stopping active statements during execution may be delayed in HANA. The internal task management in HANA is a "cooperative" multitasking approach, broadly speaking. And some parts of the query execution engine do not check for a cancellation flag often enough. This is usually the case, when checking for such a flag more often would incur a higher performance cost - and the baseline assumption is to not cancel statements.

In case, excessive runtime leads to locks that, in turn, lead to actual application blockages, it may be a good choice to consider using workload management classes for those statement. See the documentation for details on that.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda