Skip to content

Consumer Requeue -> DBAL NotNullConstraintViolationException #290

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

Closed
SchumacherFM opened this issue Dec 14, 2017 · 3 comments · Fixed by #291
Closed

Consumer Requeue -> DBAL NotNullConstraintViolationException #290

SchumacherFM opened this issue Dec 14, 2017 · 3 comments · Fixed by #291
Labels

Comments

@SchumacherFM
Copy link

Hi there,

Thanks for this great queuing framework!

It runs in Magento2 very smoothly but I have to use DBAL backend which brings an error:

The automatically created enqueue DB table structure looks:

CREATE TABLE `enqueue` (
  `id` char(36) COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:guid)',
  `published_at` bigint(20) NOT NULL,
  `body` longtext COLLATE utf8_unicode_ci,
  `headers` longtext COLLATE utf8_unicode_ci,
  `properties` longtext COLLATE utf8_unicode_ci,
  `redelivered` tinyint(1) DEFAULT NULL,
  `queue` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `priority` smallint(6) NOT NULL,
  `delayed_until` int(11) DEFAULT NULL,
  `time_to_live` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_CFC35A68E0D4FDE1` (`published_at`),
  KEY `IDX_CFC35A687FFD7F63` (`queue`),
  KEY `IDX_CFC35A6862A6DC27` (`priority`),
  KEY `IDX_CFC35A681A065DF8` (`delayed_until`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

When a consumer now requeues then the following error will occur:

[error] Consuming interrupted by exception

  [Doctrine\DBAL\Exception\NotNullConstraintViolationException]
  An exception occurred while executing 'INSERT INTO enqueue (body, headers, properties, priority, queue, redelivered) VALUES (?, ?, ?, ?, ?, ?)' with params ["msg", "{\"content_type\":\"application\\\/json\",\
  "message_id\":\"c0165f40-d05c-44f4-a3ae-2d8286a89b86\",\"timestamp\":1513248090,\"reply_to\":null,\"correlation_id\":null}", "{\"enqueue.topic_name\":\"xxx.vote.new\",\"enqueu
  e.processor_name\":\"xxx-votes\",\"enqueue.processor_queue_name\":\"default\"}", 2, "enqueue.app.default", 1]:

  SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

  [PDOException]
  SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

What am I doing wrong or is this bug related to here:

$dbalMessage = [

when on requeuing the column id has been left out ... ?

Thanks for help!

@makasim
Copy link
Member

makasim commented Dec 14, 2017

It is a bug, The consumer writes directly to db on requeue hence it does not generate a new uuid.

I don't think it was wise to go with that approach. It would be better to reuse the producer to requeue a message, like in FsConsumer::reject() method

@SchumacherFM
Copy link
Author

Ok, I'll implement that, until the core DBAL code gets fixed.

@makasim
Copy link
Member

makasim commented Dec 14, 2017

fixed since https://github.com/php-enqueue/dbal/releases/tag/0.8.11

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

Successfully merging a pull request may close this issue.

2 participants