Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ocramius opened this issue Aug 22, 2016 · 4 comments
Open

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

Ocramius opened this issue Aug 22, 2016 · 4 comments

Comments

@Ocramius
Copy link
Contributor

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.

@henrikbjorn
Copy link
Contributor

Chose the one you think is best. The reasoning seems solid.

Ocramius added a commit to Ocramius/bernard that referenced this issue Aug 22, 2016
Ocramius added a commit to Ocramius/bernard that referenced this issue Aug 22, 2016
Ocramius added a commit to Ocramius/bernard that referenced this issue Aug 22, 2016
Ocramius added a commit to Ocramius/bernard that referenced this issue Aug 22, 2016
@Ocramius
Copy link
Contributor Author

Provided patch in #252. Patch is against 0.x, since that's what I rely on, but I can also forward-port it to master for you, once it is reviewed/acceptable.

henrikbjorn added a commit that referenced this issue Dec 15, 2016
…creation

Fix #251: dbal driver - safe queue creation
henrikbjorn added a commit that referenced this issue Dec 29, 2016
…-creation' into doctrine-safe-queue-creation
acrobat pushed a commit to acrobat/bernard that referenced this issue Jul 9, 2017
acrobat pushed a commit to acrobat/bernard that referenced this issue Jul 9, 2017
acrobat pushed a commit to acrobat/bernard that referenced this issue Jul 9, 2017
acrobat pushed a commit to acrobat/bernard that referenced this issue Jul 9, 2017
@sagikazarmark
Copy link
Contributor

@acrobat I can see you worked on this. Are you planning to rebase and resubmit it?

@acrobat
Copy link
Member

acrobat commented Feb 17, 2018

Uhm let me see if I can dig this up again 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants