Giter VIP home page Giter VIP logo

Comments (6)

wolfy-j avatar wolfy-j commented on September 13, 2024 2

Предположительно поправили в последнем релизе.

from database.

roxblnfk avatar roxblnfk commented on September 13, 2024 1

Возможно пофикшено в #66

from database.

AdeAttwood avatar AdeAttwood commented on September 13, 2024 1

Possibly fixed in # 66

I think so. I haven't had this issue in a while. This was also suggested in #62 (comment)

from database.

AdeAttwood avatar AdeAttwood commented on September 13, 2024

I'm getting the same exception on SPV0 not sure if it's related. It's coming from spiral/migrations when running migrations.

while (($migration = $migrator->run()) !== null) {
    $output->writeln("+ {$migration->getState()->getName()}");
}
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT SVP0 does not exist

I think this is running execute on a CREATE TABLE statement that implicitly commits the transaction. Then when you try to commit the transaction it throws an exception that is caught and then the rollBack is called and dose not have a save point to go back to. The below snippet is from https://github.com/spiral/database/blob/master/src/Database.php#L244-L254 and if you wrap the commit in a try you get "There is no active transaction"

try {
    $result = $callback($this);
-   $this->commit();
+   try {
+       $this->commit();
+   } catch (Throwable $e) {
+       $e->getMessage(); // "There is no active transaction"
+   }

    return $result;
} catch (Throwable $e) {
    $this->rollBack();
    throw $e;
}

I have managed to fix the issue by wrapping the $this->getPDO()->commit() in $this->getPDO()->inTransaction() only commit if there is an active transaction in the driver.

try {
-    return $this->getPDO()->commit();
+    if ($this->getPDO()->inTransaction()) {
+        return $this->getPDO()->commit();
+    }
} catch (Throwable $e) {
    throw $this->mapException($e, 'COMMIT TRANSACTION');
}

It is also worth mentioning I am only getting this on php 8 it is working OK on 7.4. Don't know what the next steps are, I am happy to make a PR if your happy with the $this->getPDO()->inTransaction() fix.

from database.

roxblnfk avatar roxblnfk commented on September 13, 2024

Об ошибке PDOException: There is no active transaction:

Прошёл по всему стеку и выяснил, что транзакцию прерывает, например, CREATE TABLE в $pdo->execute().

Полагаю, что это связано с тем, что $pdo->beginTransaction() не срабатывает должным образом.

Похоже на то, что транзакция начинается (вызов $pdo->inTransaction() после beginTransaction() возвращает true), но при этом не выключается режим автоматической фиксации транзакции, как написано в документации.

Воспроизводится на php 8 + mysql (5.7, 8.0)

from database.

roxblnfk avatar roxblnfk commented on September 13, 2024

Also covered by tests in cycle/database#16

from database.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.