nextcloud / nextcloud/server

Clarification: Is APCu acceptable for `memcache.locking`?

Open
#43,895 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 29-feedback bug feature: caching feature: filesystem feature: locking feature: settings pending documentation
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Is APCu acceptable for usage for transactional file locking under any circumstances we consider "supported"? If it's acceptable, are there caveats?

Background: Last year @linuxserver set a default value of for memcache.locking that utilizes APCu in their Nextcloud image: https://github.com/linuxserver/docker-nextcloud/commit/aaa5539e72f9539724962f62eb5b355aee53d90e via linuxserver/docker-nextcloud#317.

This was apparently in response to the performance warning added in v27 (when the database is being used for locking - i.e. when Redis isn't configured): linuxserver/docker-nextcloud#319

The end result is that all LinuxServer image users are now using APCu for transactional file locking rather than the database (unless the admin has explicitly configured Redis). This achieved their goal: no longer a warning about using the database for locking.

But is this a valid configuration?

Our documentation is not 100% clear whether we support the use of APCu for memcache.locking:

We have fallback code that appears to prefer a NULL_CACHE (over using APCu as a fallback) for locking: https://github.com/nextcloud/server/blob/f2f1074396b12be31f84a3db30f7e95c501c4aab/lib/private/Memcache/Factory.php#L101-L103

My understanding is that APCu can maybe work for mod_php and some PHP-FPM operating modes. The key requirement being that the operating mode in-use must permit all processes to use a shared APCu cache. However, even if the application server layer is fine, anything happening at the command-line will not use the same APCu cache (effectively being blind to Transaction File Locking). This could lead to problems in areas like occ files commands (and possibly others) I'd think.

So is APCu acceptable at all? Is it worse - or better - than a NULL_CACHE?

TODO:

  • Confirm / get feedback
  • Create an issue in docs to track clarification / Clarify the docs in a PR
  • If "no": Adding a check that explicitly disallows APCu for memcache.locking even if specified explicitly in the config?
  • If "no": Coordinating with LinuxServer to change their image behavior
  • If "yes": Should we consider changing our default fallback behavior?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read lib/private/Memcache/Factory.php around the referenced fallback and compare it with the two linked caching and file-locking documentation pages. Establish and record whether APCu is supported for memcache.locking, including the shared-cache and command-line caveats described here; done means the documentation is unambiguous and any required follow-up is tracked.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.