Federated shares with users of the same instance can deadlock PHP-FPM – create internal shares instead
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 20/100
Piste de recherche
Start by reading the sharing implementation and the related issues #3042, #36790, and #65766 mentioned in the report. Trace how federated shares are created from the share dialog and public-link flow, and how share records are stored and removed. The requested work includes local recipient detection, link-bound internal shares, cleanup, an occ command, and a setup check; done means these paths avoid self-federated requests while preserving permissions and link revocation.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
[!TIP]
Help move this idea forward
- Use the 👍 reaction to show support for this feature.
- Avoid commenting unless you have relevant information to add; unnecessary comments create noise for subscribers.
- Subscribe to receive notifications about status changes and new comments.
Is your feature request related to a problem? Please describe.
Users can create federated shares with other users on the same instance. Nextcloud then talks to itself over HTTPS for every access to such a share. This can take down the whole instance.
There are two ways users end up with these "self-federated" shares:
- Share dialog: The owner enters
[email protected](the cloud ID of a local user) instead of justuser. The current check only prevents a federated share with the same user, not with other local users. - Public link: A logged-in user opens a public link from the same instance and uses "Add to your Nextcloud". This creates a federated share to the own instance.
What happened on our instance (Nextcloud 34.0.2, Apache + PHP-FPM, pm.max_children = 5 at the time):
- Five self-federated shares existed. When users browsed folders inside them (e.g. folders with many images), each request occupied a PHP-FPM worker, which then made an HTTPS request to the same instance and waited for a free worker.
- Once all workers were busy, they waited for each other: a deadlock. The instance stopped responding entirely for about a day, until PHP-FPM was restarted.
- The PHP-FPM log showed
server reached pm.max_children setting, Apache loggedAH01075: Error dispatching request ... (polling)for every request, andnextcloud.logshowederror while discovering ocm providerandfiles_lock: Failed to get remote lock from DAV: Gateway Timeoutfor paths inside the self-federated shares.
More workers make this less likely, but do not prevent it. Self-federated shares also have no benefit over internal shares: the data is on the same server either way.
Describe the solution you'd like
1. Share dialog: create an internal share instead
When the recipient of a federated share is a cloud ID that resolves to the own instance, Nextcloud should create a regular internal share with the local user instead, with the same permissions. The owner intended to share with exactly this user, so this is safe.
Detection should consider all names of the instance (trusted_domains, overwrite.cli.url) and normalize scheme, trailing slashes and subpaths. Our instance alone is reachable under three hostnames.
2. Public link: link-bound internal shares
For links, simply converting into an internal share would be wrong: the owner would lose the ability to revoke access by deleting the link. I'd suggest a model similar to OneDrive/SharePoint:
- When a logged-in user of the same instance opens a public link, offer "Add to my files" instead of "Add to your Nextcloud".
- This creates an internal share that is bound to the link share. Its permissions never exceed those of the link.
- In the sharing sidebar, the owner sees which users have added the link this way.
- When the link is deleted or expires, all shares bound to it are removed as well.
This keeps the semantics of a link ("whoever has the link has access, until I revoke it") while avoiding the round trip over HTTPS.
3. For existing installations
An occ command that lists existing self-federated shares (share_external entries whose remote points to the own instance) and optionally converts them, plus a setup check warning about them.
Describe alternatives you've considered
- Disabling federated sharing: not possible for us, we also use federation with other servers.
- Disabling only "Add to your Nextcloud" for public links: closes the second path, not the first.
- Lowering
davstorage.request_timeoutand settingrequest_terminate_timeoutin PHP-FPM: limits the damage, but does not fix the cause. This is what we did for now. - Converting the shares manually in the database: error-prone, since several tables are involved.
Additional context
- Version: We are on 34.0.2. The changelogs of 34.0.3 to 34.0.6 contain no change addressing this. I have not been able to test Nextcloud 35, where sharing is being reworked ("Unified sharing remote recipients", #64919; "Allow remote owners and initiators", #65915). If that already covers this case, I'd be glad for a pointer.
- #3042: A Nextcloud developer already suggested creating an internal share when the entered cloud ID belongs to the same server ("Add to your Nextcloud"). The issue was later closed because the original bug was no longer reproducible; the suggestion itself was never implemented.
- #36790: Self-federated share via "Add to your Nextcloud" leaves stale data in
oc_filecache(closed due to missing info). - #65766: An unreachable federated remote blocks the user's whole filesystem. Same underlying problem: requests to a federated remote can hold workers indefinitely.
- #3539: Two instances sharing one PHP-FPM pool deadlock on federated shares.
- Langage dominant
- PHP
- Étoiles
- 37.5k
- Forks
- 5.4k
- Merge moyen
- 1 j 13 h
- PR mergées (30 j)
- 639
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nextcloud/server
-
35-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
0. Needs triage 35-feedback bug
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
workflowengine: File entity reuses the node of the first "Tag assigned" event for all later events in the same processPeut-être pris @lazerg l’a pris il y a 2 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Contacts import aborts with TypeError when vCards have no UID (TextImporter structure)Peut-être pris @SebastianKrupinski l’a pris il y a 6 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
nextcloud/server#66486 · 2 commentaires · 2 réactions · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Unified search: screen reader hears "No matching results" on mobile even when there are resultsPeut-être pris @lazerg l’a pris il y a 10 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nextcloud/server
Issues similaires
-
[Sync EN] stream: document the errors of the stream_context_*() and stream filter functions (#6091)Ouvertesync-en
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Automattic/blocks-engine#6318 ·
Les mainteneurs répondent en général sous 1 jour
-
Update: Laravel Cheat Sheet - middleware examples for the bootstrap/app.php layout (small update)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
OWASP/CheatSheetSeries#2990 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour