# Segment:Update Cron Failing Since Update

**URL:** <https://forum.mautic.org/t/segment-update-cron-failing-since-update/25368>\
**Category:** Mautic 4 Install/Upgrade Support\
**Created:** [September 12, 2022, 11:51pm UTC](https://forum.mautic.org/t/segment-update-cron-failing-since-update/25368 "2022-09-12T23:51:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![healthstatus1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/healthstatus1/32/961_2.png) [@healthstatus1](https://forum.mautic.org/u/healthstatus1)\
**Post date:** [September 12, 2022, 11:51pm UTC](https://forum.mautic.org/t/segment-update-cron-failing-since-update/25368/1 "2022-09-12T23:51:57Z")

</div>

**Your software** 4.4.2  
_My PHP version is_ : 7.4.30  
_My MariaDB version is_ (delete as applicable): 10.5.10-MariaDB-1:10.5.10+maria~xenial-log

**Updating/Installing Errors**  
_I am_ (delete as applicable): Updating  
_Upgrading/installing via_ (delete as applicable) : Command Line

_These errors are showing in the installer_ :

_These errors are showing in the Mautic log_ :

**Your problem**  
_My problem is_ : When running mautic:segments:update cron job

An exception occurred while executing ‘SELECT count(leadIdPrimary) count, m  
ax(leadIdPrimary) maxId, min(leadIdPrimary) minId FROM (SELECT DISTINCT l.i  
d as leadIdPrimary FROM leads l WHERE ((l.state IS NULL) OR (l.state NOT IN  
())) AND (l.id IN (SELECT par2.lead\_id FROM lead\_tags\_xref par2 WHERE par2  
.tag\_id IN ())) AND (l.id IN (SELECT par4.lead\_id FROM lead\_tags\_xref par4  
WHERE par4.tag\_id IN ())) AND (NOT EXISTS(SELECT NULL FROM page\_hits par7 W  
HERE (par7.lead\_id = l.id) AND ((par7.url = ?) OR (par7.url IS NULL)))) AND  
(l.id NOT IN (SELECT par8.lead\_id FROM lead\_lists\_leads par8 WHERE par8.le  
adlist\_id = ?))) sss’ with params [“https://mydomain.com/beneficiary-form-c  
omplete/”, 5]:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
n your SQL syntax; check the manual that corresponds to your MariaDB server  
version for the right syntax to use near ‘))) AND (l.id IN (SELECT par2.le  
ad\_id FROM lead\_tags\_xref par2 WHERE par2.tag…’ at line 1

In Exception.php line 18:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
n your SQL syntax; check the manual that corresponds to your MariaDB server  
version for the right syntax to use near ‘))) AND (l.id IN (SELECT par2.le  
ad\_id FROM lead\_tags\_xref par2 WHERE par2.tag…’ at line 1

In PDOStatement.php line 117:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
n your SQL syntax; check the manual that corresponds to your MariaDB server  
version for the right syntax to use near ‘))) AND (l.id IN (SELECT par2.le  
ad\_id FROM lead\_tags\_xref par2 WHERE par2.tag…’ at line 1

_Steps I have tried to fix the problem_ :  
schema status check  
schema migration migrate  
schema migration update --force  
( and I get: SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX `IDX_1AE3441319EB6921`; check that it exists)

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 15, 2022, 5:44pm UTC](https://forum.mautic.org/t/segment-update-cron-failing-since-update/25368/2 "2022-09-15T17:44:36Z")

</div>

Hi,

I might be wrong here, but looking at the query it looks like it generates an empty IN statement.

> [@healthstatus1](#):
>
> OR (l.state NOT IN  
> ())) AND (l.id IN (SELECT par2.lead\_id FROM lead\_tags\_xref par2 WHERE par2  
> .tag\_id IN ())) AND (l.id IN (SELECT par4.lead\_id FROM lead\_tags\_xref par4  
> WHERE par4.tag\_id IN ()))

This usually indicates issue with segment filter config.

What happens, if you create a segment with only one simple filter? Does it fire/update OK?

---

<div class="post-metadata">

**Author:** ![healthstatus1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/healthstatus1/32/961_2.png) [@healthstatus1](https://forum.mautic.org/u/healthstatus1)\
**Post date:** [September 15, 2022, 6:07pm UTC](https://forum.mautic.org/t/segment-update-cron-failing-since-update/25368/3 "2022-09-15T18:07:26Z")

</div>

Just got this figured out, in the upgrade, all the conditions to create the segment except for one were wiped out.

Replacing the values in the statement solved the problem.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [September 17, 2022, 6:07am UTC](https://forum.mautic.org/t/segment-update-cron-failing-since-update/25368/4 "2022-09-17T06:07:30Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
