Skip to content

SQLSTATE[23000]: Integrity constraint violation: error while running sales_clean_orders cron job #35302

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
Usik2203 opened this issue Apr 13, 2022 · 8 comments
Assignees
Labels
Issue: ready for confirmation Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@Usik2203
Copy link
Contributor

Preconditions (*)

I see next error while running sales_clean_orders cron job
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento2.salesrule_customer, CONSTRAINT SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES salesrule (rule_id) ON DELETE CASCADE), query was: INSERT INTO salesrule_customer () VALUES ()

Steps to reproduce (*)

1. Set Pending Payment Order Lifetime (minutes) to 1
Screenshot 2022-04-13 at 17 16 31
2. Set schedule for sales_clean_orders to * * * * * in app/code/Magento/Sales/etc/crontab.xml:14
3. Create Cart Price Rule
Screenshot 2022-04-13 at 17 51 58
Screenshot 2022-04-13 at 17 52 45
4. Login as Customer and place order with applied Cart Price Rule
Screenshot 2022-04-13 at 17 57 32
5 Go to sales_order table and set status pending_payment for current order
Screenshot 2022-04-13 at 17 59 45
6 Go Marketing -> Cart Price Rule and remove Cart Price Rule
Screenshot 2022-04-13 at 18 01 36
6 Go to console and run bin/magento cron:run --group="default"
Screenshot 2022-04-13 at 18 04 46
7 Go to cron_schedule table you will see
Screenshot 2022-04-13 at 18 06 22

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento2.salesrule_customer, CONSTRAINT SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES salesrule (rule_id) ON DELETE CASCADE), query was: INSERT INTO salesrule_customer () VALUES ()

Expected result (*)

I don't see mentioned error while running sales_clean_orders cron job

Actual result (*)

Screenshot 2022-04-13 at 18 06 22

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento2.salesrule_customer, CONSTRAINT SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES salesrule (rule_id) ON DELETE CASCADE), query was: INSERT INTO salesrule_customer () VALUES ()

Related issues(*)

#27918
#19230
#16779

@m2-assistant
Copy link

m2-assistant bot commented Apr 13, 2022

Hi @Usik2203. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@Usik2203
Copy link
Contributor Author

@magento I am working on this

@m2-community-project m2-community-project bot added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Apr 14, 2022
@tuyennn
Copy link
Member

tuyennn commented Nov 28, 2022

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @tuyennn. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Hi @tuyennn, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@tuyennn
Copy link
Member

tuyennn commented Nov 28, 2022

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @tuyennn. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Hi @tuyennn, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: ready for confirmation Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants