...
In-memory caches store pages in configured DataRegion
. Page for specific cache group allocated in some Segment
of data region.
So, unlike persistent caches it more convinient and error-prone to create snapshot of the DataRegion with all caches in it.
During creation of snapshot node must track all page changes which can be implemented by the listener of write locks in PageMemoryNoStoreImpl
Moreover, pages of data region can store entries from different cache-groups.
So for in-memory caches snapshots it proposed to use per entry storage.
Every entry in cache group will be saved as is to corresponding file.
3. Persistent pages contains CRC to make sure data integrity while storing on disk:
...
must be properly prepared and saved during snapshot.
High-level snapshot creation algorithm steps:
- Under PME locks setup page before writeLock listener.
Listener must be invoked under writeLock of page but before code that trying to acquire lock. - Iterate each page of DataRegion and write page entries to corresponding cache-group snapshot files.
- Inside listener:
- store pageId that was handled by listener
- handle page like on step2.
After algorithm ends each file will contain consistent copy of in-memory cache group.
Restore
Prerequisites:
- Restored data region is empty - there are no any caches stored in itcache group not exists on cluster.
- Count of nodes in cluster are the same as in time of creation (this restriction can be eliminated in Phase 2 of IEP implementation).
- All nodes in cluster has snapshot locally.
Steps:
High-level snapshot restore algorithm steps:
- Create corresponding cachesBlock data region exclusively on each node - any attempt of usage (cache creation) must be blocked.
- Restore all saved data into data regionmetadata.Restore all saved metadata
- Iterate saved entries and put them as local cache entries.
- Wait all nodes complete step 2 and 3.
- Start caches that belongs to restored data region.
...
There are a couple of alternatives to implement backup copies of inmemory caches that was rejected during initial analyzes:
- Store entries instead of full data region copy
The idea of this approach is to store entries in the file instead of pagesfull data region copy on the disk.
- Pros:
- cache group granularity like in persistent snapshots.
- smaller snapshot size in case of snapshotting specific cache group. Currently, cache group snapshot granularity not supported by persistent snapshots.
- backward compatibility of BinaryObject only required. PageIO strusture can be changed
- ability to implement primary-only mode.
- Mostly sequential writes.
- Cons:
- restore must setup all Ignite internals strustured regarding restored offheap data.
Such code can be difficult to implement and maintain
Cons:- restore require more time because per-entry local put operation must be invoked on each node.
- On demand persistence
The idea of this approach is to reuse PDS infrastucture and persistent snapshot code by introducing new cache mode "PDS_ON_DEMAND".
This mode will use persitence code but with WAL and checkpoint disabled. So on creating snapshot regular checkpoint will be performed.
After checkpoint PDS files are ready to be copied to snapshot folder.- Pros:
- Code reuse.
- Cons:
- Additional configuration on user-side required (set new mode for DataRegion).
- All Ignite codebase needs to be aware of new mode - baseline, PDS, WAL, checkpoint, etc.
- PDS page stores additional data - storage overhead.
- shmem usage
The idea of this approach is to use shared memory feature of Linux.- Pros:
- Easy to implement (questioneable).
- Same approach used by other vendors to implement in-memory cluster restarts.
- Cons:
- OS specific.
- Only for certain scenarios. Doesn't cover all use-cases.
...