-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Store storage availability in database #13641
Conversation
@@ -91,6 +99,36 @@ public static function getNumericStorageId($storageId) { | |||
} | |||
|
|||
/** | |||
* @return bool |
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.
May also return null
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.
Specifically cannot return null - see database schema
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.
What is L108 then for?
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.
Ah, sorry, it was late and I wasn't thinking properly 😄
|
Hmm, I'm trying to fix these test failures, and it seems there is a cyclic dependency. This PR introduces the There are a couple of solutions that I can see: either move the home storage creation so that it occurs before the filesystem is set up, or create the home storage while the storage is being mounted (so trigger that from |
Nice work. I wonder if it's too early for this, as we wanted to revamp the DB anyway here: #11261 (comment) But that might fit with the new scheme, too. |
@@ -91,6 +99,36 @@ public static function getNumericStorageId($storageId) { | |||
} | |||
|
|||
/** | |||
* @return bool | |||
*/ | |||
public function getAvailability() { |
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'd merge this into one function where all information is returned. With the current design two queries will be fired to get availability and last checked
040cde0
to
1eb24d9
Compare
4f89a52
to
3a6c0a8
Compare
Right, I think I've got it now. The availability checker is implemented as a storage wrapper, and uses the following algorithm for every storage call:
If the call to the storage itself throws a One issue noticed with this new code: For this PR to be useful, storages need to throw @icewind1991 Tell me if I'm doing anything wrong 😄 TODO:
|
This approach seems fine by me |
3a6c0a8
to
c784d7e
Compare
c784d7e
to
796b4f6
Compare
Rebase conflict was the |
796b4f6
to
2ba1019
Compare
Rebase conflict was license headers and version.php. |
2ba1019
to
6ce67af
Compare
👍 nice work |
|
b96796c
to
a69b752
Compare
@MorrisJobke This only works if the storage cooperates and throws StorageNotAvailableException. Try merging |
a69b752
to
79e131f
Compare
A new inspection was created. |
Storage status is saved in the database. Failed storages are rechecked every 10 minutes, while working storages are rechecked every request. Using the files_external app will recheck all external storages when the settings page is viewed, or whenever an external storage is saved.
This usually doesn't cause issues, but in unit tests sometimes a wrapped storage is passed to Filesystem::mount() and gets rewrapped, hitting the XDebug function nesting level limit when used.
79e131f
to
75a5e6e
Compare
A new inspection was created. |
@MorrisJobke Could you re-review this please? |
Also cc @PVince81 |
$this->storage = $storage; | ||
// only wrap if not already wrapped | ||
if (!($this->storage instanceof Wrapper)) { | ||
$this->storage = $this->loader->wrap($this, $this->storage); |
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.
Is this required by this PR or is an additional fix ?
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.
Without this fix, unit tests will fail, since our unit tests attempt to re-wrap storages sometimes causing function nesting limit failures. In the actual codebase it makes no difference, since we never pass a wrapped storage to be re-wrapped.
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.
Actually, this is a poor fix. There may be usecases where instead of a Storage being passed in, a Wrapper is (aka pre-wrapped storage) but still needs to be wrapped with the other storage wrappers too.
Didn't destroy the known universe 👍 (ran a few smashbox tests and encryption + ext storage) |
Store storage availability in database
Regression, cannot create user: #18129 |
Storage status is saved in the database. Failed storages are rechecked every 10 minutes, while working storages are rechecked every request. Using the files_external app will recheck all external storages when the settings page is viewed, or whenever an external storage is saved.
The advantage of this is that failed external storages will not impede page loading, apart from every 10 minutes when a recheck is performed. To test, simply create several external storages will valid details other than the credentials (SFTP is nice and slow for this), then load the files page. On master, it will load slowly as timeouts occur. With this PR, it will load slowly once, then be fast for 10 minutes.
The counterpart to this is #13515, which eliminates the slowdown on the settings pages.
Fixes #13531
cc @PVince81 @icewind1991 @DeepDiver1975
P.S. This is my first work involving database stuff. It's likely that I got something wrong, so review those bits in particular! The unit tests should help though 😄