<p>This could maybe help you track down the issue:</p>
<p>The search index table has all of its rows removed and re-built any time an element is saved. You could look at the timestamp of the error and look for the entry / global / category / etc. that was edited around the same time.</p>
<p>It seems like the element being entered into the search index is being entered twice with the primary key <code>720757-slug-0-1</code></p>
<p>The element's id is 720757 and it's trying to save the slug <code>achillessehne </code> please note that there is definitely a space in this slug, which is a little bit odd.</p>
<p>Can you check your entries for ones that have the slug <code>achillessehne </code>? Perhaps there are more than one with the same slug that were generated and are erroring on search re-index? Let us know if you spot some more info and we can continue to debug!</p>

CC BY-SA 4.0
2023-03-07T07:50:16.653Z
Thanks cherrykoda! I assume there's no easy way to prevent the cms re-building the complete search index table? It's a craft instance with ~1200 entries and ~15 sites for multilingual/multinational use. Yesterday the queue backed up to 800k site index jobs… :S

Yes, I found an entry with this slug and removed the spaces. I have no idea how they managed to insert a space into a slug… I didn't find a duplicate slug. At least not in the same site. So it's only once for the site /de but again for /ch-de and /at-de. But i assume this should not be a problem, is it?
Sandro
CC BY-SA 4.0
2023-03-08T00:37:15.670Z
Glad you found that! Multiple sites should not be an issue, since the call to the search index includes a site ID in addition to the rest of the data (your original error is site id #1). I completely understand the nerves with having so many entries.

Can you look to see if you're still getting the same error? Is there a new one?
cherrykoda
CC BY-SA 4.0
2023-03-08T07:23:57.100Z
Yeah there are multiple new ones. Pretty much all of them is because the SiteCopy plugin is being used pretty frequently. With that many sites, the copy process—which is handled by the queue—takes quite some time. And during this time, the entry that is being copied must not be edited, otherwise the queue breaks again. I looked at this directly with Gold Interactive, the devs of SiteCopy: https://github.com/Goldinteractive/craft3-sitecopy/issues/34
Sandro
CC BY-SA 4.0
2023-03-08T09:17:18.267Z
If your site relies on SiteCopy and a large data set - you really should add more queue workers so that the queue isn't backed up waiting on just one. This sounds a bit like you may need to re-evaluate the architecture to support a large amount of site data.
cherrykoda
CC BY-SA 4.0
2023-03-09T10:03:14.247Z
Is there a queue worker you can recommend?
Sandro
CC BY-SA 4.0
2023-03-09T14:20:08.813Z
This is a really comprehensive guide to handling queue workers, with a few options and their pros/cons. https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms

The best option is going to depend on your site's setup and hosting.
cherrykoda
CC BY-SA 4.0
2023-03-10T08:36:50.613Z
Thanks for the article, we will look into that
Sandro
CC BY-SA 4.0
2023-03-07T04:54:19.933Z
2023-03-07T04:54:19.933Z
cherrykoda
<p>I have queue jobs called &quot;Syncing element contents&quot; which more often than not fail and shut down the whole control panel because the queue just gets backed up to over 170k jobs.</p>
<p>I guess this error means that Craft wants to do something with an entry that somehow already exists. My client can't tell me what action exactly he does when this error appears so there isn't much more info I can give about this.</p>
<p>I need to know what triggers this error so I can fix it and prevent it from happening in the future.</p>
<p>Please find below the stack trace and the <code>project.yaml</code> for any further system info.</p>
<hr />
<p><strong>Stack Trace:</strong></p>
<pre><code>The SQL being executed was: INSERT INTO `searchindex` (`elementId`, `attribute`, `fieldId`, `siteId`, `keywords`) VALUES (720757, 'slug', 0, 1, ' achillessehne ') {&quot;memory&quot;:10963232} 
2023-03-06 12:36:54 [queue.ERROR] [yii\db\IntegrityException] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '720757-slug-0-1' for key 'PRIMARY' in /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php:1302
Stack trace:
#0 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement-&gt;execute()
#1 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command-&gt;internalExecute('INSERT INTO `se...')
#2 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/helpers/Db.php(953): yii\db\Command-&gt;execute()
#3 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(433): craft\helpers\Db::insert('{{%searchindex}...', Array)
#4 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(188): craft\services\Search-&gt;_indexKeywords(Object(craft\elements\Entry), ' achillessehne ', 'slug')
#5 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/jobs/UpdateSearchIndex.php(65): craft\services\Search-&gt;indexElementAttributes(Object(craft\elements\Entry), Array)
#6 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/Queue.php(246): craft\queue\jobs\UpdateSearchIndex-&gt;execute(Object(craft\queue\Queue))
#7 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue-&gt;handleMessage(997398, 'O:34:&quot;craft\\que...', 300, 1)
#8 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(183): yii\queue\cli\Queue-&gt;handleMessage(997398, 'O:34:&quot;craft\\que...', 300, 1)
#9 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(158): craft\queue\Queue-&gt;executeJob()
#10 [internal function]: craft\queue\Queue-&gt;craft\queue\{closure}(Object(Closure))
#11 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#12 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(166): yii\queue\cli\Queue-&gt;runWorker(Object(Closure))
#13 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/controllers/QueueController.php(82): craft\queue\Queue-&gt;run()
#14 [internal function]: craft\controllers\QueueController-&gt;actionRun()
#15 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction-&gt;runWithParams(Array)
#17 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller-&gt;runAction('run', Array)
#18 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module-&gt;runAction('queue/run', Array)
#19 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application-&gt;runAction('queue/run', Array)
#20 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application-&gt;_processActionRequest(Object(craft\web\Request))
#21 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application-&gt;handleRequest(Object(craft\web\Request))
#22 /home/httpd/vhosts/domain/root/web/index.php(21): yii\base\Application-&gt;run()
#23 {main}

Next yii\db\IntegrityException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '720757-slug-0-1' for key 'PRIMARY'
The SQL being executed was: INSERT INTO `searchindex` (`elementId`, `attribute`, `fieldId`, `siteId`, `keywords`) VALUES (720757, 'slug', 0, 1, ' achillessehne ') in /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Schema.php:676
Stack trace:
#0 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema-&gt;convertException(Object(PDOException), 'INSERT INTO `se...')
#1 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command-&gt;internalExecute('INSERT INTO `se...')
#2 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/helpers/Db.php(953): yii\db\Command-&gt;execute()
#3 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(433): craft\helpers\Db::insert('{{%searchindex}...', Array)
#4 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(188): craft\services\Search-&gt;_indexKeywords(Object(craft\elements\Entry), ' achillessehne ', 'slug')
#5 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/jobs/UpdateSearchIndex.php(65): craft\services\Search-&gt;indexElementAttributes(Object(craft\elements\Entry), Array)
#6 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/Queue.php(246): craft\queue\jobs\UpdateSearchIndex-&gt;execute(Object(craft\queue\Queue))
#7 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue-&gt;handleMessage(997398, 'O:34:&quot;craft\\que...', 300, 1)
#8 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(183): yii\queue\cli\Queue-&gt;handleMessage(997398, 'O:34:&quot;craft\\que...', 300, 1)
#9 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(158): craft\queue\Queue-&gt;executeJob()
#10 [internal function]: craft\queue\Queue-&gt;craft\queue\{closure}(Object(Closure))
#11 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#12 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(166): yii\queue\cli\Queue-&gt;runWorker(Object(Closure))
#13 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/controllers/QueueController.php(82): craft\queue\Queue-&gt;run()
#14 [internal function]: craft\controllers\QueueController-&gt;actionRun()
#15 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction-&gt;runWithParams(Array)
#17 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller-&gt;runAction('run', Array)
#18 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module-&gt;runAction('queue/run', Array)
#19 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application-&gt;runAction('queue/run', Array)
#20 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application-&gt;_processActionRequest(Object(craft\web\Request))
#21 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application-&gt;handleRequest(Object(craft\web\Request))
#22 /home/httpd/vhosts/domain/root/web/index.php(21): yii\base\Application-&gt;run()
#23 {main}
Additional Information:
Array
(
    [0] =&gt; 23000
    [1] =&gt; 1062
    [2] =&gt; Duplicate entry '720757-slug-0-1' for key 'PRIMARY'
)
</code></pre>
<hr />
<p><strong>project.yaml:</strong></p>
<pre class="lang-yaml prettyprint-override"><code>{
  &quot;require&quot;: {
    &quot;carlcs/craft-redactorcustomstyles&quot;: &quot;4.0.3&quot;,
    &quot;craftcms/cms&quot;: &quot;4.3.10&quot;,
    &quot;craftcms/feed-me&quot;: &quot;5.0.5&quot;,
    &quot;craftcms/redactor&quot;: &quot;3.0.3&quot;,
    &quot;goldinteractive/craft-sitecopy&quot;: &quot;1.0.4&quot;,
    &quot;nystudio107/craft-cookies&quot;: &quot;4.0.0&quot;,
    &quot;nystudio107/craft-seomatic&quot;: &quot;4.0.20&quot;,
    &quot;putyourlightson/craft-blitz&quot;: &quot;4.4.0&quot;,
    &quot;putyourlightson/craft-dashboard-begone&quot;: &quot;2.0.0&quot;,
    &quot;putyourlightson/craft-elements-panel&quot;: &quot;2.0.0&quot;,
    &quot;putyourlightson/craft-sprig&quot;: &quot;2.5.1&quot;,
    &quot;vaersaagod/geomate&quot;: &quot;v2.1.0&quot;,
    &quot;vaersaagod/matrixmate&quot;: &quot;2.1.2&quot;,
    &quot;vlucas/phpdotenv&quot;: &quot;^3.4.0&quot;
  },
  &quot;autoload&quot;: {
    &quot;psr-4&quot;: {
      &quot;modules\\&quot;: &quot;modules/&quot;
    }
  },
  &quot;config&quot;: {
    &quot;sort-packages&quot;: true,
    &quot;optimize-autoloader&quot;: true,
    &quot;platform&quot;: {
      &quot;php&quot;: &quot;8.0.2&quot;
    },
    &quot;allow-plugins&quot;: {
      &quot;craftcms/plugin-installer&quot;: true,
      &quot;yiisoft/yii2-composer&quot;: true
    }
  },
  &quot;scripts&quot;: {
    &quot;post-root-package-install&quot;: [
      &quot;@php -r \&quot;file_exists('.env') || copy('.env.example', '.env');\&quot;&quot;
    ]
  }
}
</code></pre>

CC BY-SA 4.0
2023-03-07T09:39:55.580Z
How are you processing your queue? I've had this error before after following Andrew's guide to setting up a systemd daemon (https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms), because in the article he sets up dual daemons, and in my case for some reason they often seemed to get into a race situation where they'd both attempt to process the same job. Switching down to a single daemon fixed it for me.
James Smith
CC BY-SA 4.0
2023-03-07T10:16:38.720Z
We're just using the standard craft queue without any additional daemons, cron jobs or anything like this
Sandro
<logs><queue>
Integrity constraint violation blocks queue
# Integrity constraint violation blocks queue

(Asked by: username_0 on 2023-03-06)

I have queue jobs called "Syncing element contents" which more often than not fail and shut down the whole control panel because the queue just gets backed up to over 170k jobs.
I guess this error means that Craft wants to do something with an entry that somehow already exists. My client can't tell me what action exactly he does when this error appears so there isn't much more info I can give about this.
I need to know what triggers this error so I can fix it and prevent it from happening in the future.
Please find below the stack trace and the project.yaml for any further system info.

Stack Trace:
The SQL being executed was: INSERT INTO `searchindex` (`elementId`, `attribute`, `fieldId`, `siteId`, `keywords`) VALUES (720757, 'slug', 0, 1, ' achillessehne ') {"memory":10963232} 
2023-03-06 12:36:54 [queue.ERROR] [yii\db\IntegrityException] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '720757-slug-0-1' for key 'PRIMARY' in /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php:1302
Stack trace:
#0 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('INSERT INTO `se...')
#2 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/helpers/Db.php(953): yii\db\Command->execute()
#3 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(433): craft\helpers\Db::insert('{{%searchindex}...', Array)
#4 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(188): craft\services\Search->_indexKeywords(Object(craft\elements\Entry), ' achillessehne ', 'slug')
#5 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/jobs/UpdateSearchIndex.php(65): craft\services\Search->indexElementAttributes(Object(craft\elements\Entry), Array)
#6 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/Queue.php(246): craft\queue\jobs\UpdateSearchIndex->execute(Object(craft\queue\Queue))
#7 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage(997398, 'O:34:"craft\\que...', 300, 1)
#8 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(183): yii\queue\cli\Queue->handleMessage(997398, 'O:34:"craft\\que...', 300, 1)
#9 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(158): craft\queue\Queue->executeJob()
#10 [internal function]: craft\queue\Queue->craft\queue\{closure}(Object(Closure))
#11 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#12 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(166): yii\queue\cli\Queue->runWorker(Object(Closure))
#13 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/controllers/QueueController.php(82): craft\queue\Queue->run()
#14 [internal function]: craft\controllers\QueueController->actionRun()
#15 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#17 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('run', Array)
#18 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('queue/run', Array)
#19 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('queue/run', Array)
#20 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#21 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#22 /home/httpd/vhosts/domain/root/web/index.php(21): yii\base\Application->run()
#23 {main}

Next yii\db\IntegrityException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '720757-slug-0-1' for key 'PRIMARY'
The SQL being executed was: INSERT INTO `searchindex` (`elementId`, `attribute`, `fieldId`, `siteId`, `keywords`) VALUES (720757, 'slug', 0, 1, ' achillessehne ') in /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Schema.php:676
Stack trace:
#0 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'INSERT INTO `se...')
#1 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('INSERT INTO `se...')
#2 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/helpers/Db.php(953): yii\db\Command->execute()
#3 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(433): craft\helpers\Db::insert('{{%searchindex}...', Array)
#4 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/services/Search.php(188): craft\services\Search->_indexKeywords(Object(craft\elements\Entry), ' achillessehne ', 'slug')
#5 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/jobs/UpdateSearchIndex.php(65): craft\services\Search->indexElementAttributes(Object(craft\elements\Entry), Array)
#6 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/Queue.php(246): craft\queue\jobs\UpdateSearchIndex->execute(Object(craft\queue\Queue))
#7 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage(997398, 'O:34:"craft\\que...', 300, 1)
#8 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(183): yii\queue\cli\Queue->handleMessage(997398, 'O:34:"craft\\que...', 300, 1)
#9 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(158): craft\queue\Queue->executeJob()
#10 [internal function]: craft\queue\Queue->craft\queue\{closure}(Object(Closure))
#11 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#12 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/queue/Queue.php(166): yii\queue\cli\Queue->runWorker(Object(Closure))
#13 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/controllers/QueueController.php(82): craft\queue\Queue->run()
#14 [internal function]: craft\controllers\QueueController->actionRun()
#15 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#17 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('run', Array)
#18 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('queue/run', Array)
#19 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('queue/run', Array)
#20 /home/httpd/vhosts/domain/root/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#21 /home/httpd/vhosts/domain/root/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#22 /home/httpd/vhosts/domain/root/web/index.php(21): yii\base\Application->run()
#23 {main}
Additional Information:
Array
(
    [0] => 23000
    [1] => 1062
    [2] => Duplicate entry '720757-slug-0-1' for key 'PRIMARY'
)


project.yaml:
{
  "require": {
    "carlcs/craft-redactorcustomstyles": "4.0.3",
    "craftcms/cms": "4.3.10",
    "craftcms/feed-me": "5.0.5",
    "craftcms/redactor": "3.0.3",
    "goldinteractive/craft-sitecopy": "1.0.4",
    "nystudio107/craft-cookies": "4.0.0",
    "nystudio107/craft-seomatic": "4.0.20",
    "putyourlightson/craft-blitz": "4.4.0",
    "putyourlightson/craft-dashboard-begone": "2.0.0",
    "putyourlightson/craft-elements-panel": "2.0.0",
    "putyourlightson/craft-sprig": "2.5.1",
    "vaersaagod/geomate": "v2.1.0",
    "vaersaagod/matrixmate": "2.1.2",
    "vlucas/phpdotenv": "^3.4.0"
  },
  "autoload": {
    "psr-4": {
      "modules\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "8.0.2"
    },
    "allow-plugins": {
      "craftcms/plugin-installer": true,
      "yiisoft/yii2-composer": true
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  }
}

**Tags:** logs, queue

> **Comments:**
> **username_1**: How are you processing your queue? I've had this error before after following Andrew's guide to setting up a systemd daemon (https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms), because in the article he sets up dual daemons, and in my case for some reason they often seemed to get into a race situation where they'd both attempt to process the same job. Switching down to a single daemon fixed it for me.  
> **username_0**: We're just using the standard craft queue without any additional daemons, cron jobs or anything like this  

---

## 1 answers

### Answer by username_2 on 2023-03-07. Score: 1

This could maybe help you track down the issue:

The search index table has all of its rows removed and re-built any time an element is saved. You could look at the timestamp of the error and look for the entry / global / category / etc. that was edited around the same time.

It seems like the element being entered into the search index is being entered twice with the primary key `720757-slug-0-1`

The element's id is 720757 and it's trying to save the slug `achillessehne`  please note that there is definitely a space in this slug, which is a little bit odd.

Can you check your entries for ones that have the slug `achillessehne` ? Perhaps there are more than one with the same slug that were generated and are erroring on search re-index? Let us know if you spot some more info and we can continue to debug!

> **Comments:**
> **username_0**: Thanks username_2! I assume there's no easy way to prevent the cms re-building the complete search index table? It's a craft instance with ~1200 entries and ~15 sites for multilingual/multinational use. Yesterday the queue backed up to 800k site index jobs… :S  Yes, I found an entry with this slug and removed the spaces. I have no idea how they managed to insert a space into a slug… I didn't find a duplicate slug. At least not in the same site. So it's only once for the site /de but again for /ch-de and /at-de. But i assume this should not be a problem, is it?  
> **username_2**: Glad you found that! Multiple sites should not be an issue, since the call to the search index includes a site ID in addition to the rest of the data (your original error is site id #1). I completely understand the nerves with having so many entries.  Can you look to see if you're still getting the same error? Is there a new one?  
> **username_0**: Yeah there are multiple new ones. Pretty much all of them is because the SiteCopy plugin is being used pretty frequently. With that many sites, the copy process—which is handled by the queue—takes quite some time. And during this time, the entry that is being copied must not be edited, otherwise the queue breaks again. I looked at this directly with Gold Interactive, the devs of SiteCopy: https://github.com/Goldinteractive/craft3-sitecopy/issues/34  
> **username_2**: If your site relies on SiteCopy and a large data set - you really should add more queue workers so that the queue isn't backed up waiting on just one. This sounds a bit like you may need to re-evaluate the architecture to support a large amount of site data.  
> **username_0**: Is there a queue worker you can recommend?  
> **username_2**: This is a really comprehensive guide to handling queue workers, with a few options and their pros/cons. https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms  The best option is going to depend on your site's setup and hosting.  
> **username_0**: Thanks for the article, we will look into that  

---

