-
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
Strictly forbid FS access or any I/O operations during app load process #30818
Comments
Ideally we should also add a hook "onload" at the time where all apps were loaded. Then apps can start their initial operations in exactly that hook. |
GitMate.io thinks possibly related issues are #8451 (files_versions app has problems if two FS operations happen on the same second), #14305 (App access to certain groups fails), #26226 ([master] LDAP app not loaded during upgrade), #17245 (Prevent version app operations when file is locked), and #515 (cannot load app - app is null). |
The app loading is currently a little messy an mostly in old static legacy code. I would prefer to enforce the order of loading app types and throw an exception when loading the apps of one type has not finished but a new load app or load apps call is made. That is more general and works without adding more state handling to the already complicated storage layer. The current order of app types seems to be
Unfortunately, sometimes an array of app types is given. It is pure luck that the apps are then loaded in the right order. The code literally iterates over the apps and checks if their type matches an element of the array. So if Documented are the following types https://doc.owncloud.org/server/latest/developer_manual/app/fundamentals/info.html#types
I cannot find type Then there is type Finally, we have several places where just loadApp is used. Sometimes by iterating over all enabled apps, then loading them. Eg the repair steps: https://github.com/owncloud/core/blob/master/core/Command/Maintenance/Repair.php#L80-L98 or the already mentioned In my opinion if you request to load an app, all previous app types (aka all enabled apps of previous types) need to be loaded before the requested app can be loaded. No idea why I propose this new order of apps:
What a mess ... |
only use once in one special environment --> we could kill that |
in an ideal world the loading of apps is a mutli phase process:
|
no idea if we should load such apps for e.g. unautenticated requests? |
Forcing a loading order won't really solve the issue: a logging app might need to store the log file somewhere in the ownCloud filesystem, or log additional actions depending if the user is an admin or not. Similarly, a session app could need to load certificates from the user's data folder. What I see is a dependency problem due to cycles in the dependeny tree. From my point of view, the specific issue we have is that the filesystem requires user management during the loading phase. You have user_management -> encryption -> filesystem -> back to user_management. This is the problem: the filesystem requires user_management even though it's being loaded. Although we won't be able to avoid component dependency (components will need to interact with eachother anyway), we MUST limit the interaction outside of the component initialization. This means that, during the component creation we must just inject the dependencies without interact with them. If there is any initialization required for a component, that should be delayed until it's going to be used (classic lazy initialization - as long as it's properly documented this shouldn't be an easy) Once everything is properly wired, it shouldn't matter where the call is made. As for how we can limit this interaction, I don't think it's really possible, or at least not easy. Most of the things that can be done in the app.php file can be done anywhere. If we remove the app.php to rely on the Application.php file for initialization, everything can be moved to the new place, so it won't solve the problem by itself. |
so we seem to agree that app.php should go away and info.xml should be used to register to any event bus/dispatcher and after all apps have been setup the routing will consume what is necessary? What does that mean? order of 'loading' apps no longer matters? but the order might still determine if password is checked against ldap or the db first. I guess if we compile the classloading a la symphony, we might be able to gain a huge performance improvement. Then how do we get there? fix all the apps? add hooks/whatever is needed to core if it is missing? encryption will be a pain. how long do we want to maintain backward compatability? |
In app.php from some apps, objects are created that already access the filesystem through the FS API (aka Node API) of ownCloud. This triggers an early initialization while some other plugins might not have been registered yet.
We should strictly forbid such FS access or any other I/O operations while app code is still being loaded.
Some idea how to do it: have AppManager store a loading state:
Then in the FS classes / API, check said flag. If the flag is different than "STATE_LOADED", throw an exception.
It is likely that many apps will not be able to function properly without this. So in cases where FS access is needed during initialization, we need to find another solution.
@butonic @patrickjahns @DeepDiver1975 @jvillafanez
The text was updated successfully, but these errors were encountered: