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

[10.0] sale_exception: Remove side effect from api.constrains #916

Merged
merged 1 commit into from
Sep 27, 2019

Conversation

guewen
Copy link
Member

@guewen guewen commented Aug 13, 2019

The method called by 'sale_check_exception' has a side effect, it writes
on 'exception.rule' + on the Many2many relation between it and
sale.order(.line). When decorated by @api.constrains, any error during
the method will be caught and re-raised as "ValidationError".
This part of code is very prone to concurrent updates as 2 sales having
the same exception will both write on the same 'exception.rule'.
A concurrent update (OperationalError) is re-raised as ValidationError,
and then is not retried properly.

Calling the same method in create/write has the same effect than
@api.constrains without shadowing the exception type.

Full explanation:
OCA/server-tools#1642

@guewen guewen changed the title sale_exception: Remove side effect from api.constrains [10.0] sale_exception: Remove side effect from api.constrains Aug 13, 2019
Copy link
Contributor

@florian-dacosta florian-dacosta left a comment

Choose a reason for hiding this comment

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

I am actually not sure what is the purpose of this constrains feature.
But Ok for me to remove the api.constrains as discussed already.

@guewen
Copy link
Member Author

guewen commented Aug 14, 2019

Travis failed because postgres was not running? 😵
Is Travis dying?

@pedrobaeza
Copy link
Member

Hehe, no, but you have to update to latest MQT template: https:/OCA/maintainer-quality-tools/blob/master/sample_files/.travis.yml

The reason behind is that Travis has switched its base OS and now it doesn't bundle PostgreSQL by default.

Copy link
Member

@yvaucher yvaucher left a comment

Choose a reason for hiding this comment

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

LGTM

@guewen
Copy link
Member Author

guewen commented Aug 14, 2019

Hehe, no, but you have to update to latest MQT template: https:/OCA/maintainer-quality-tools/blob/master/sample_files/.travis.yml

Thanks!

Copy link
Contributor

@sebalix sebalix left a comment

Choose a reason for hiding this comment

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

Travis is red, tests are failing on sale_triple_discount but it doesn't seem related to the PR (it was already failing before).

@rafaelbn rafaelbn closed this Aug 30, 2019
@rafaelbn rafaelbn reopened this Aug 30, 2019
@rafaelbn rafaelbn added this to the 10.0 milestone Aug 30, 2019
@rafaelbn
Copy link
Member

Hi @guewen , just checking if travis is 💚 to merge but it is 🔴 😢

continuous-integration/travis-ci/pr — The Travis CI build failed

Could take a look please? Thanks

@guewen
Copy link
Member Author

guewen commented Sep 13, 2019

Hi @rafaelbn,

The travis error is unrelated, a test failing in sale_triple_discount :(

@MiquelRForgeFlow
Copy link
Contributor

you should do a rebase

The method called by 'sale_check_exception' has a side effect, it writes
on 'exception.rule' + on the Many2many relation between it and
sale.order(.line). When decorated by @api.constrains, any error during
the method will be caught and re-raised as "ValidationError".
This part of code is very prone to concurrent updates as 2 sales having
the same exception will both write on the same 'exception.rule'.
A concurrent update (OperationalError) is re-raised as ValidationError,
and then is not retried properly.

Calling the same method in create/write has the same effect than
@api.constrains without shadowing the exception type.

Full explanation:
OCA/server-tools#1642
@guewen guewen force-pushed the 10.0-sale-exception-no-side-effect branch from 302e368 to aeb1f32 Compare September 13, 2019 12:31
@rafaelbn rafaelbn closed this Sep 26, 2019
@rafaelbn rafaelbn reopened this Sep 26, 2019
@rafaelbn
Copy link
Member

/ocabot merge

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 10.0-ocabot-merge-pr-916-by-rafaelbn-bump-no, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Sep 26, 2019
Signed-off-by rafaelbn
OCA-git-bot added a commit that referenced this pull request Sep 27, 2019
Signed-off-by rafaelbn
@OCA-git-bot
Copy link
Contributor

It looks like something changed on 10.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 10.0-ocabot-merge-pr-916-by-rafaelbn-bump-no, awaiting test results.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@OCA-git-bot
Copy link
Contributor

It looks like something changed on 10.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 10.0-ocabot-merge-pr-916-by-rafaelbn-bump-no, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Sep 27, 2019
Signed-off-by rafaelbn
@OCA-git-bot OCA-git-bot merged commit aeb1f32 into OCA:10.0 Sep 27, 2019
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at c8a9171. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants