Closed egistli closed 1 year ago
This class should be configurable to enable or disable dynamic structure changes to avoid this problem. This force to manage the table structure manually.
I have the same issue. As a result, just enabling this long handler in your app changes the way how the transactions are handled by the database engine. This happens implicitly and it is really tricky and difficult to debug.
The easiest solution would be to have a constructor parameter initializeTable=true/false
, if false then any DDL statements won't be executed.
There is already a constructor argument allowing to bypass the table initialization: $initialize
or in the upcomming v2 $skipTableInitialization
. See https://github.com/waza-ari/monolog-mysql/blob/master/src/MySQLHandler.php#L61
First, thanks for the library, it's handy and doing well out-of-box.
However the
CREATE TABLE IF NOT EXISTS...
SQL in theinitialize
method may interrupt transactions unintentionally.For the flow as following:
The rollback in step 4. will do nothing, because at step 3. the
initialize
method will be called and after the execution of SQLCREATE TABLE...
, the transaction will be committed implicitly.