Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

add note re using redis with file locking app #1182

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions admin_manual/configuration_files/files_locking_enabling.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
===========================
Using the Files Locking App
---------------------------
===========================

The Files Locking application enables ownCloud to lock files while reading or
writing to and from backend storage. The purpose of the app is to avoid file
Expand All @@ -16,4 +17,28 @@ underlying filesystem.
The Files Locking app has no configuration options; all you need to do is
enable or disable it on your Apps page.

.. figure:: ../images/files_locking_app.png
.. figure:: ../images/files_locking_app.png

We recommend using `Redis <http://redis.io/>`_ as your ownCloud memcache when
you enable the Files Locking app. Memcached, the popular distributed memory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a major misunderstanding here.

The files_locking app is an old app that locked on filesystem level. That app does not need memcache at all.

Since 8.1, there is an experimental new file locking mechanism, totally unrelated to the files_locking app. That one can be enabled with "filelocking.enabled". That one requires redis.
In the future, if the new file locking mechanism works well, it will obsolete the old files_locking app.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the new file locking mechanism works well, it will obsolete the old files_locking app.

Really? I thought that files_locking is for locking against concurrent processes to the ownCloud server on the server side (filesystem level).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are both about concurrency.

The difference is that files_locking use flock on filesystem level.

The new experimental locking uses a custom-lock implementation based on redis, and locks on View level. This makes it so that we can have "bigger" transactions during a lock.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? I thought that files_locking is for locking against concurrent processes to the ownCloud server on the server side (filesystem level).

There is no way to lock files in PHP reliably against other processes. 🙈 – PHP uses advisory based locking per default, see http://php.net/manual/en/function.flock.php and especially enjoy:

flock() uses mandatory locking instead of advisory locking on Windows. Mandatory locking is also supported on Linux and System V based operating systems via the usual mechanism supported by the fcntl() system call: that is, if the file in question has the setgid permission bit set and the group execution bit cleared. On Linux, the file system will also need to be mounted with the mand option for this to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the new experimental locking can lock parent folders. So for example you cannot rename a folder if someone exclusively locked a file inside it (while writing data into it)

caching system, is not suitable for a file locking app because it is designed
to improve dynamic Web site performance. It is not designed to store locks, and
data can disappear from the cache at any time. Redis is more than an object
cache like Memcached; it is also a key-value store, so it guarantees that
cached objects are available for as long as they are needed. Redis is available
on most Linux distributions, and requires a simple configuration in your
``config.php`` file, like this example::

'memcache.local' => '\OC\Memcache\redis',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace \ with double backslashes \\ (it was wrong in the sample config, fixed now)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't matter as long as the character following the \ doesn't have a special escaped meaning

'redis' => array(
'host' => 'localhost',
// can also be a unix domain socket:
'/tmp/redis.sock'
'port' => 6379,
'timeout' => 0.0,
// Optional, if undefined SELECT will not run and will use Redis
// Server's default DB Index.
'dbindex' => 0,
),

See ``config.sample.php`` to see configuration examples for all memcaches.