-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
[16.0][IMP] fs_storage: invalidate filesystem cache when connection fails #320
[16.0][IMP] fs_storage: invalidate filesystem cache when connection fails #320
Conversation
3707e52
to
302a29a
Compare
302a29a
to
91f673f
Compare
91f673f
to
3c08fcc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JordiMForgeFlow Thank you for this improvement. A few comments... In the same time can you add a file named 320.feature
into the fs_storage/readme/newsframent with a description of this new feature. The content will be used at merge time to fill the addon's changelog.
Could you also update the USAGE.rst file to describe the new parameters?
3c08fcc
to
0d6a88a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
invalidate_cache_on_error maybe is not even needed as a setting and what it adds should be just the standard behavior, but not a big deal.
20a1f72
to
17fb3c3
Compare
@lmignon after trying using The |
36a5624
to
4b50530
Compare
My concern is about the performance cost when the root directory contains hundred of thousand files... To limit the scope of the |
I agree. We should probably create a file on 1st check (eg: |
4b50530
to
c076645
Compare
@sebalix can you try by installing it from https://github.com/fsspec/filesystem_spec ? |
Regarding connection failure, I replaced the use of the deprecated functions in
Maybe it's not related at all. |
f2ffb04
to
7f810aa
Compare
7f810aa
to
1f4c9f0
Compare
1f4c9f0
to
46aab5b
Compare
/ocabot merge minor |
What a great day to merge this nice PR. Let's do it! |
Congratulations, your PR was merged at 916060f. Thanks a lot for contributing to OCA. ❤️ |
# Use a marker file to limit the scope of the LS command for performance. | ||
try: | ||
self._check_connection(self.__fs) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some tests, we are still facing connections issues and the current implementation doesn't cover it: OSError: Socket is closed
This errors arrives only after some time (several hours, workers have a high lifespan here and FS object is never recreated meanwhile).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebalix maybe then we should not store the FS object at all in the slot, and always call to _get_filesystem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module can also be used in contexts of heavy traffic between odoo and external filesystems. This is particularly the case when it is used to manage Odoo's default attachment storage. In such circumstances, the cost of the reconnection required each time the fs proxy would be recreated is not negligible. Perhaps it would be a good idea to set up a 'keep-alive' mechanism via a cron running every 'X' minutes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure to understand the cron approach regarding this in-memory object?
But yes, the only fix that is working for us right now is to return a new FS object every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand it would be to have a cron that invalidates the __fs slot after some time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cron process could updates memory objects of other Odoo process (workers)? Not sure it's possible 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The raise e
is an issue here (testing the code during a workshop), it is blocking somehow the queue-job.
Clearing the fsspec cache should be enough here, so a new connection will be established in case of error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, after one day of testing, we encountered no connection issues with the help of the skip_instance_cache
parameter of fsspec
(set in the options). This will add some overhead but at least we are safe... dealing with this cache in Odoo seems error prone (connection stability, configuration of the SFTP server...).
I don't know how huge is this overhead, load testing will tell us I guess.
Fixes #319
CC @LoisRForgeFlow