Truncate Doctrine\DBAL\Exception\DriverException message if too long #5277

Closed
opened 2026-01-22 15:03:16 +01:00 by admin · 1 comment
Owner

Originally created by @shtrom on GitHub (Sep 28, 2016).

Originally assigned to: @Ocramius on GitHub.

Hi have an issue---triggered by ownCloud and an erroneous vCard with a duplicated PHOTO field---where a database insertion request into MySQL via the Doctrine DBAL fails.

Essentially, the blob inserted is too big for MySQL, and it issues a Syntax error or access violation: 1118 The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size.” which gets transformed into a Doctrine\DBAL\Exception\DriverException.

The message for the exception is An exception occurred while executing [QUERY] with params [PARAMS]. This is where the issue with Doctrine is: the blob is about 9MiB at this stage, and it is dumped verbatim as part of the PARAMS bit in the error message. This makes the Exception a bit hard to understand, as it is not concise enough, and this makes log files grow at a very very high rate.

A solution to this problem would be to either

  • truncate or ellipsise PARAMS longer than a given threshold in the error message, e.g., BEGIN:VCARD\r ... END:VCARD\r(line ending might or might not be a good idea to rely on)
  • not reproduce blobs, and replace them altogether with something like BLOB of 9MiB, or
  • a combination of both: BEGIN:VCARD\r [about 9MiB of blob] END:VCARD\r.

Note that my example is with ownCloud and vCards, but the problem is more generic, with any blob too big for comfortable display.

Originally created by @shtrom on GitHub (Sep 28, 2016). Originally assigned to: @Ocramius on GitHub. Hi have an issue---triggered by ownCloud and an erroneous vCard with a duplicated `PHOTO` field---where a database insertion request into MySQL via the Doctrine DBAL fails. Essentially, the blob inserted is too big for MySQL, and it issues a `Syntax error or access violation: 1118 The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size.”` which gets transformed into a `Doctrine\DBAL\Exception\DriverException`. The message for the exception is `An exception occurred while executing [QUERY] with params [PARAMS]`. This is where the issue with Doctrine is: the blob is about 9MiB at this stage, and it is dumped verbatim as part of the `PARAMS` bit in the error message. This makes the Exception a bit hard to understand, as it is not concise enough, and this makes log files grow at a very very high rate. A solution to this problem would be to either - truncate or ellipsise `PARAMS` longer than a given threshold in the error message, e.g., `BEGIN:VCARD\r ... END:VCARD\r`(line ending might or might not be a good idea to rely on) - not reproduce blobs, and replace them altogether with something like `BLOB of 9MiB`, or - a combination of both: `BEGIN:VCARD\r [about 9MiB of blob] END:VCARD\r`. Note that my example is with ownCloud and vCards, but the problem is more generic, with any blob too big for comfortable display.
admin added the Invalid label 2026-01-22 15:03:16 +01:00
admin closed this issue 2026-01-22 15:03:16 +01:00
Author
Owner

@shtrom commented on GitHub (Sep 28, 2016):

Wrong repo, see doctrine/dbal#2523; sorry about the noise.

@shtrom commented on GitHub (Sep 28, 2016): Wrong repo, see doctrine/dbal#2523; sorry about the noise.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5277