public interface ExtinctionFilter
Environment.discardExtinctRecords(com.sleepycat.je.Transaction, java.util.Set<java.lang.String>, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.ScanFilter, java.lang.String) to
discard and purge extinct records. The ExtinctionFilter is
specified by calling EnvironmentConfig.setExtinctionFilter(com.sleepycat.je.ExtinctionFilter).
A non-null extinction filter must be specified before calling
Environment.discardExtinctRecords.
The benefit of record extinction, compared to explicit record deletion,
is that an entry is not logged or replicated for each extinct record,
resulting in less resource usage. Only a single entry is logged and
replicated when calling Environment.discardExtinctRecords, and a
small amount of cleaner metadata is written when extinct records are
counted obsolete. Performance impacts to be aware of are as follows.
Environment.discardExtinctRecords. This scan will have little
or no impact on ongoing operations, as long as Btree nodes (BINs in
particular) are in the JE cache as recommended. The scan counts the
size of the specified extinct records, logs this change to JE cleaner
metadata, and removes the extinct records from the Btree. The changes
to the Btree are logged at the next checkpoint.Environment.discardExtinctRecords, using record extinction is not
recommended for discarding many, very small sets of records (for
example, discarding millions of sets of 100 records or less).Record extinction is intended for optimized record deletion in cases where a large set of records is no longer needed and the keys of the extinct records will not be accessed again. It is the responsibility of the application to ensure that this condition holds. If extinct records are accessed, JE does not provide many of the usual transactional guarantees:
Below are examples of applications where keys are never accessed again, and therefore could be considered extinct.
Each call to Environment.discardExtinctRecords specifies a key
range, along with an optional filter, in a set of one ore more databases.
When the transaction passed to this method is committed (or auto-commit is
used), JE will asynchronously remove the specified records from the Btree
and count them obsolete to cause log cleaning, which will reclaim unused
disk space over time.
The getExtinctionStatus(java.lang.String, boolean, byte[]) method in this interface, on the other
hand, must return either ExtinctionFilter.ExtinctionStatus.EXTINCT or
ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT for all record keys specified in
all previous calls to Environment.discardExtinctRecords.
This is necessary to avoid integrity errors and is the responsibility of
the application. If ExtinctionFilter.ExtinctionStatus.NOT_EXTINCT is returned
for a key previously specified as extinct using
Environment.discardExtinctRecords, JE integrity checks may
incorrectly fail, and an EnvironmentFailureException may be
thrown.
The getExtinctionStatus method should return
ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT when
Environment.discardExtinctRecords may have been called for a
given key, but the status of the key is temporarily unknown to the
application. For example, the application may use metadata stored in a
JE Database to determine the extinction status of a record. During
startup when this metadata has not yet been read from the Database,
ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT should be returned.
Although not recommended, it is possible to call
Environment.discardExtinctRecords and implement a
getExtinctionStatus method that always returns
ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT. This will not cause integrity
errors, but is likely to result in lower performance and will disable
certain internal integrity checks for all records.
The reason for lowered performance when
ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT is returned is that the
getExtinctionStatus method is used by the JE cleaner to quickly
purge extinct records without a Btree lookup. When
getExtinctionStatus returns ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT
for records that are actually extinct, performance will be less than optimal
for two reasons.
For a given set of extinct records, the application should perform actions in the following sequence.
ExtinctionFilter.getExtinctionStatus method
to return ExtinctionFilter.ExtinctionStatus.EXTINCT for the extinct records.Environment.discardExtinctRecords for the extinct
records.If step 2 is omitted, or step 2 is performed after step 3, performance will be suboptimal as described above. If step 1 is not performed first, normal transactional guarantees may be violated as described further above.
Although record extinction is asynchronous, for testing and debugging
the Environment.isRecordExtinctionActive(long) may be useful for
determining when related tasks are complete on a given node.
In a replicated environment, Environment.discardExtinctRecords
may not be called until all nodes have been upgraded to JE 18.1 or later,
and it will throw IllegalStateException if this is not the case.
The Environment.isRecordExtinctionAvailable() method can be used
for determining this in advance.
| Modifier and Type | Interface and Description |
|---|---|
static class |
ExtinctionFilter.ExtinctionStatus
Extinction status values returned by
getExtinctionStatus(java.lang.String, boolean, byte[]). |
| Modifier and Type | Method and Description |
|---|---|
ExtinctionFilter.ExtinctionStatus |
getExtinctionStatus(String dbName,
boolean dups,
byte[] key)
Implemented to determine whether a given key is extinct.
|
ExtinctionFilter.ExtinctionStatus getExtinctionStatus(String dbName, boolean dups, byte[] key)
ExtinctionFilter.ExtinctionStatus.EXTINCT or
ExtinctionFilter.ExtinctionStatus.MAYBE_EXTINCT for all extinct records
identified by calls to Environment.discardExtinctRecords(com.sleepycat.je.Transaction, java.util.Set<java.lang.String>, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.ScanFilter, java.lang.String).dbName - the name of the JE database containing the record.dups - whether the JE database has duplicate keys, which is
assumed to mean it is a secondary database.key - is the primary key of the record. If dups is true, this is
the record's data and is assumed to be a primary key.Copyright © 2024. All rights reserved.