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

[17.0] Oca port from 16.0 to 17.0 pr 387 422 #459

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

lmignon
Copy link
Contributor

@lmignon lmignon commented Oct 3, 2024

No description provided.

Defines specific dependencies to support case where te authentication is optional.
This change fix an issue that prevented the system to retry a call to the
application in case of a DB concurrency error if this error is defined as
retryable.

By default, any call to the application is retried in case of a DB concurrency
if retryable. The 'retry' mechanism is implemented at the early stage of the processing
of a request in case of specific postgreSQL errors. When a call is made to
a fastapi application, the specific handler for the request is placed further
down the stack. Before this change, any error that occurred in the specific
fastapi handler was catch by the Fastapi processing stack and never bubbled up
to the early stage of the processing where the 'retry' mechanism is implemented.

This change fix this issue by putting in place a way to make some specific
exceptions bubble up the fastapi processing stack through the event loop required
to transform WSGI to ASGI.
This change is a complete rewrite of the way the transactions are managed when
integrating a fastapi application into Odoo.

In the previous implementation, specifics error handlers were put in place to
catch exception occurring in the handling of requests made to a fastapi application
and to rollback the transaction in case of error. This was done by registering
specifics error handlers methods to the fastapi application using the 'add_exception_handler'
method of the fastapi application. In this implementation, the transaction was
rolled back in the error handler method.

This approach was not working as expected for several reasons:

- The handling of the error at the fastapi level prevented the retry mechanism
  to be triggered in case of a DB concurrency error. This is because the error
  was catch at the fastapi level and never bubbled up to the early stage of the
  processing of the request where the retry mechanism is implemented.
- The cleanup of the environment and the registry was not properly done in case
  of error. In the **'odoo.service.model.retrying'** method, you can see that
  the cleanup process is different in case of error raised by the database
  and in case of error raised by the application.

This change fix these issues by ensuring that errors are no more catch at the
fastapi level and bubble up the fastapi processing stack through the event loop
required to transform WSGI to ASGI. As result the transactional nature of the
requests to the fastapi applications is now properly managed by the Odoo framework.
@lmignon
Copy link
Contributor Author

lmignon commented Oct 3, 2024

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 17.0-ocabot-merge-pr-459-by-lmignon-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d2e638d into OCA:17.0 Oct 3, 2024
7 checks passed
@lmignon lmignon deleted the oca-port-from-16.0-to-17.0-pr-387-422 branch October 3, 2024 06:19
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 3fa322b. 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.

2 participants