Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger] Adds option to force indexes creation in Mysql platform for Doctrine transport #45007

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
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CHANGELOG

4.4.0
-----

* Added option for forcing mysql indexes creation for doctrine transport
* Added support for auto trimming of Redis streams.
* `InMemoryTransport` handle acknowledged and rejected messages.
* Made all dispatched worker event classes final.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public function providePlatformSql(): iterable
/**
* @dataProvider setupIndicesProvider
*/
public function testSetupIndices(string $platformClass, array $expectedIndices)
public function testSetupIndices(string $platformClass, array $expectedIndices, array $options = [])
{
$driverConnection = $this->createMock(DBALConnection::class);
$driverConnection->method('getConfiguration')->willReturn(new Configuration());
Expand Down Expand Up @@ -448,7 +448,7 @@ public function testSetupIndices(string $platformClass, array $expectedIndices)
->willReturn([]);
$driverConnection->method('getDatabasePlatform')->willReturn($platformMock);

$connection = new Connection([], $driverConnection);
$connection = new Connection($options, $driverConnection);
$connection->setup();
}

Expand All @@ -459,6 +459,12 @@ public function setupIndicesProvider(): iterable
[['delivered_at']],
];

yield 'MySQL with forced index' => [
MySQL57Platform::class,
[['queue_name'], ['available_at'], ['delivered_at']],
['force_indexes_creation' => true],
];

yield 'Other platforms' => [
AbstractPlatform::class,
[['queue_name'], ['available_at'], ['delivered_at']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Connection
'queue_name' => 'default',
'redeliver_timeout' => 3600,
'auto_setup' => true,
'force_indexes_creation' => false,
];

/**
Expand All @@ -53,6 +54,7 @@ class Connection
* * queue_name: name of the queue
* * redeliver_timeout: Timeout before redeliver messages still in handling state (i.e: delivered_at is not null and message is still in table). Default 3600
* * auto_setup: Whether the table should be created automatically during send / get. Default : true
* * force_indexes_creation: Whether indexes should be created also on mysql
*/
private $configuration = [];
private $driverConnection;
Expand Down Expand Up @@ -397,7 +399,7 @@ private function getSchema(): Schema
->setNotnull(false);
$table->setPrimaryKey(['id']);
// No indices on queue_name and available_at on MySQL to prevent deadlock issues when running multiple consumers.
if (!$this->driverConnection->getDatabasePlatform() instanceof MySqlPlatform) {
if ($this->configuration['force_indexes_creation'] || !$this->driverConnection->getDatabasePlatform() instanceof MySqlPlatform) {
$table->addIndex(['queue_name']);
$table->addIndex(['available_at']);
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.