Skip to content

DBAL-based queue constantly raises SQL-level errors #251

@Ocramius

Description

@Ocramius

As per

try {
$this->connection->insert('bernard_queues', ['name' => $queueName]);
} catch (\Exception $e) {
// Because SQL server does not support a portable INSERT ON IGNORE syntax
// this ignores error based on primary key.
}
, bernard tries to constantly bash the DB with INSERT statements that will fail.

While this seems to be acceptable at first, some database engines mark transactions with failed SQL statements as "failed transactions", rendering the entire DB connection unusable.

Few things to be done here

  • wrap the entire statement in a transaction (safest way)
  • use INSERT IGNORE (not always supported, therefore not going there)
  • do a SELECT and then an INSERT (relatively low-risk, since queues don't get destroyed/recreated often)

I'll provide a patch for this today, if this seems reasonable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions