Skip to content
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

[FW][FIX] point_of_sale: fix memory error #124375

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Jun 8, 2023

When there are too many (millions) of POS order lines associated to opened POS sessions we get too many taxes, most are duplicated. This causes a MemoryError.

Example queries from a real DB:

> select count(distinct r.account_tax_id) from pos_order_line l join pos_order o on o.id = l.order_id join pos_session s on s.id = o.session_id join account_tax_pos_order_line_rel r on r.pos_order_line_id = l.id where s.state != 'closed'
+-------+
| count |
|-------|
| 24    |
+-------+
> select count(r.account_tax_id) from pos_order_line l join pos_order o on o.id = l.order_id join pos_session s on s.id = o.session_id join account_tax_pos_order_line_rel r on r.pos_order_line_id = l.id where s.state != 'closed'
+---------+
| count   |
|---------|
| 2504539 |
+---------+

opw-3295467

Forward-Port-Of: #124194
Forward-Port-Of: #124119

@robodoo
Copy link
Contributor

robodoo commented Jun 8, 2023

@fw-bot
Copy link
Contributor Author

fw-bot commented Jun 8, 2023

@aj-fuentes @KangOl cherrypicking of pull request #124119 failed.

stdout:

Auto-merging addons/point_of_sale/models/account_tax.py
CONFLICT (content): Merge conflict in addons/point_of_sale/models/account_tax.py

stderr:

20:58:28.601103 git.c:455               trace: built-in: git cherry-pick 5a0c37375e4fce21650f38c3f00db661da5a0c3a
error: could not apply 5a0c37375e4... [FIX] point_of_sale: fix memory error
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
----------
status:

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jun 8, 2023
@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels Jun 8, 2023
When there are too many (millions) of POS order lines associated to
opened POS sessions we get too many taxes, most are duplicated. This
causes a MemorryError.

Example queries from a real DB:
```
> select count(distinct r.account_tax_id) from pos_order_line l join pos_order o on o.id = l.order_id join pos_session s on s.id = o.session_id join account_tax_pos_order_line_rel r on r.pos_order_
 line_id = l.id where s.state != 'closed'
+-------+
| count |
|-------|
| 24    |
+-------+
> select count(r.account_tax_id) from pos_order_line l join pos_order o on o.id = l.order_id join pos_session s on s.id = o.session_id join account_tax_pos_order_line_rel r on r.pos_order_line_id =
  l.id where s.state != 'closed'
+---------+
| count   |
|---------|
| 2504539 |
+---------+
```

opw-3295467

X-original-commit: 14ff7de
@aj-fuentes aj-fuentes force-pushed the saas-16.2-saas-12.3-fix_mem_error-afu-y4bH-fw branch from cf8dac7 to 52e30f1 Compare June 9, 2023 08:24
@aj-fuentes
Copy link
Contributor

@KangOl I fixed the conflict. Note that I'm not sure if one of the new methods would be better or not regarding the optimization of fetch.
Also beware that I had to use the newer invalidate_recordset.

@C3POdoo C3POdoo requested review from a team and rhe-odoo and removed request for a team June 9, 2023 08:27
@KangOl
Copy link
Contributor

KangOl commented Jun 14, 2023

@robodoo r+

robodoo pushed a commit that referenced this pull request Jun 14, 2023
When there are too many (millions) of POS order lines associated to
opened POS sessions we get too many taxes, most are duplicated. This
causes a MemorryError.

Example queries from a real DB:
```
> select count(distinct r.account_tax_id) from pos_order_line l join pos_order o on o.id = l.order_id join pos_session s on s.id = o.session_id join account_tax_pos_order_line_rel r on r.pos_order_
 line_id = l.id where s.state != 'closed'
+-------+
| count |
|-------|
| 24    |
+-------+
> select count(r.account_tax_id) from pos_order_line l join pos_order o on o.id = l.order_id join pos_session s on s.id = o.session_id join account_tax_pos_order_line_rel r on r.pos_order_line_id =
  l.id where s.state != 'closed'
+---------+
| count   |
|---------|
| 2504539 |
+---------+
```

opw-3295467

closes #124375

X-original-commit: 14ff7de
Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
@robodoo robodoo temporarily deployed to merge June 14, 2023 09:52 Inactive
@robodoo robodoo closed this Jun 14, 2023
@fw-bot fw-bot deleted the saas-16.2-saas-12.3-fix_mem_error-afu-y4bH-fw branch June 28, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants