GridGain Developers Hub

Persistence Defragmentation

Overview

The persistent store enables users to store their data durably on disk, still benefiting from the in-memory nature of Apache Ignite. Data is stored in files created for every primary or backup partition assigned to that node and in an additional file for all user indexes. Files in the filesystem are allocated lazily (only if some data is stored in a particular partition) and grow automatically when more data is added. The files cannot shrink even if all data is removed. The system only marks such files for further reuse. GridGain can only create or reuse pages for user data but never clear them from files.

Therefore the GridGain persistent data can only grow and never shrinks. It doesn’t cause any problems as once created page can be reused multiple times in most use cases. However, in certain cases, it is possible that the cache contains very little data but occupies large chunks of disk space because a significant volume of data was removed.

Defragmentation enables a user to shrink data files and claim back disk space.

Performing Defragmentation

Defragmentation is a costly operation in terms of disk IO. To avoid slowing down user operations, do not execute it on a regular node joined to the cluster. To perform defragmentation, you need to request it first on a particular node or set of nodes and then restart them.

Starting Defragmentation

To request defragmentation, execute the following command:

control.sh --defragmentation schedule --nodes <consistentIds> [--caches <cacheNames>]
control.bat --defragmentation schedule --nodes <consistentIds> [--caches <cacheNames>]

After the manual restart, the node with the requested defragmentation enters a special mode called maintenance mode. The node in maintenance mode doesn’t join the rest of the cluster but remains isolated until defragmentation is completed (or canceled by explicit user request). After that, the user has to restart the node one more time: it will exit maintenance mode and return to normal operations (joining the cluster and starting to serve regular workload).

Stopping Defragmentation

When a node executes defragmentation, it is possible to cancel it. To stop defragmentation, run the following command available in the control utility:

control.sh --host <hostName> --port <port> --defragmentation cancel
control.bat --host <hostName> --port <port> --defragmentation cancel