Skip to content

[FIX] records: use temp table in replacing refs #224

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jjmaksoud
Copy link
Contributor

@jjmaksoud jjmaksoud commented Mar 3, 2025

For the jsonb company dependent indirect references when replacing record refs, building the query using the original id mapping input can generate a large query based on the number of references being updated, leading to a stack depth limit exceeded error.

We can use the mapping saved in the temp table _upgrade_rrr instead.

TBG-1752

@robodoo
Copy link
Contributor

robodoo commented Mar 3, 2025

Pull request status dashboard

@jjmaksoud
Copy link
Contributor Author

upgradeci retry with always only documents_project_sale in version 18.0

@jjmaksoud jjmaksoud requested review from a team and asno-odoo March 4, 2025 08:45
@aj-fuentes
Copy link
Contributor

What examples do we have of such issue? Isn't this a problem of the caller to replace_records_reference_batch? Or that we should implement something perhaps splitting the id mapping?

@jjmaksoud
Copy link
Contributor Author

i saw this so far only in documents upgrade when replacing folders with documents here
example request 2592340: has over 360,000 folder mappings and the new query was fast ( <2s on the test server)
I think the subquery should be okay because the number of companies is expected to be low, the explode bucket size is manageable, and the mapping table has an index

@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from cd641d9 to de159d9 Compare March 4, 2025 10:56
@KangOl
Copy link
Contributor

KangOl commented Mar 4, 2025

Can you add a test?

@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from de159d9 to 7bdd490 Compare March 6, 2025 09:14
@jjmaksoud
Copy link
Contributor Author

The test depends on odoo/odoo#200509

@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from 7bdd490 to 324ea17 Compare March 6, 2025 10:28
@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from 324ea17 to 65d35c3 Compare March 19, 2025 09:42
@jjmaksoud
Copy link
Contributor Author

the community PR is merged and the test is now green

@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from 65d35c3 to 44c3584 Compare March 19, 2025 15:07
@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from 44c3584 to 8ab406a Compare March 20, 2025 14:10
Copy link
Contributor

@KangOl KangOl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add tests for the new assert function to expect they behave correctly in all expected cases.

@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch 2 times, most recently from 17335f2 to 49c5b20 Compare March 28, 2025 08:51
@jjmaksoud
Copy link
Contributor Author

Updated the assert methods, and ended up using a temp table for the assertNotUpdated as well instead of raising a psql exception.
Also added some test cases for the new assert functions. They can be used together, but the known limitation at the moment is that the same method cannot be used at the same time for a multiple tables.

Two contextmanager methods added to UnitTestCase to assert
wether records in the database are updated or not.
The assert requires a table name and an optional list of ids.
If ids are provided, those specific records will be checked
if updated or not. If no ids are provided then the validation
will be based on the insert or update of any record of that
relation.
For the jsonb company dependent indirect references when
replacing record refs, building the query using the
original id mapping input can generate a large query
based on the number of references being updated, leading
to a 'stack depth limit exceeded' error.

We can use the mapping saved in the temp table
_upgrade_rrr instead.
@jjmaksoud jjmaksoud force-pushed the master-replace-cmp-dep-maji branch from 49c5b20 to 44e4d51 Compare April 14, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants