public class ExtinctionScanner extends Object implements EnvConfigObserver
RecordExtinction and DatabaseExtinction tasks.
When the application calls 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)
(record extinction) or Environment.removeDatabase(com.sleepycat.je.Transaction, java.lang.String) or
Environment.truncateDatabase(com.sleepycat.je.Transaction, java.lang.String, boolean) (DB extinction), we store a scan
record in an internal scan DB and queue the scan task.
The scan DB is a replicated DB, but the scan records themselves may be replicated or non-replicated as described below. (This mixing is only possible for internal DBs, and is also used for the DbTree naming DB.)
The scan task is always performed independently on each node in a rep group, and therefore update and deletion of the scan record are non-replicated operations. Recovery will re-queue the scan task for all scan records not yet deleted.
For now, although a thread executor is used, it is limited to just use one thread. So for now, all extinction tasks will execute serially. If using multiple threads becomes necessary, some synchronization changes will be needed.
| Modifier and Type | Field and Description |
|---|---|
TestHook<?> |
dbBeforeWriteTaskHook |
static JEVersion |
TEST_MIN_JE_VERSION |
| Constructor and Description |
|---|
ExtinctionScanner(@NonNull EnvironmentImpl envImpl) |
| Modifier and Type | Method and Description |
|---|---|
void |
deleteCompletedRecordScans(Set<Long> scanIds)
After a checkpoint, delete the scans previously returned by
getCompletedRecordScans(). |
long |
discardExtinctRecords(@NonNull Locker locker,
@NonNull Set<String> dbNames,
@Nullable DatabaseEntry beginKey,
@Nullable DatabaseEntry endKey,
@Nullable ScanFilter filter,
@NonNull String label)
Inserts the scan record in the DB and queues the scan for execution.
|
void |
ensureDbExtinction(DatabaseImpl dbImpl)
Called during recovery when a NameLN delete/truncate is not followed by
the appropriate MapLN deletion.
|
void |
envConfigUpdate(DbConfigManager configManager,
EnvironmentMutableConfig ignore)
Notifies the observer that one or more mutable properties have been
changed.
|
void |
executeRecoveredTasks()
After recovery, queue any incomplete scans for execution.
|
Set<Long> |
getCompletedRecordScans()
Get a copy of the completed scan IDs before starting a checkpoint.
|
long |
getLastLocalId() |
long |
getLastReplicatedId() |
static JEVersion |
getMinJEVersion() |
boolean |
isEmpty() |
boolean |
isEnabled() |
boolean |
isScanTaskActive(long id) |
static long |
materializeKey(DatabaseEntry keyEntry) |
void |
prepareForDbExtinction(ReplicationContext repContext)
Must be called before writing a NameLN, when
startDbExtinction(com.sleepycat.je.dbi.DatabaseImpl)
will be called, i.e., for a DB remove/truncate operation. |
void |
recoverIncompleteTasks()
During recovery, save incomplete scan tasks after reading them from the
scans DB.
|
void |
replay(byte[] scanKey,
byte[] scanData)
Queues a task to process a scan LN that was replayed on this replica.
|
void |
requestShutdown() |
void |
setLastIds(long lastRepScanID,
long lastNonRepScanID) |
void |
shutdown() |
void |
startDbExtinction(DatabaseImpl dbImpl)
Used after transaction commit or non-transactional operation end in
these cases:
purge the deleted database after a commit of
Environment.removeDatabase
purge the deleted database after a commit of
Environment.truncateDatabase
purge the newly created database after an abort of
Environment.truncateDatabase
|
public static JEVersion TEST_MIN_JE_VERSION
public TestHook<?> dbBeforeWriteTaskHook
public ExtinctionScanner(@NonNull EnvironmentImpl envImpl)
public static JEVersion getMinJEVersion()
public void shutdown()
public void requestShutdown()
public void envConfigUpdate(DbConfigManager configManager, EnvironmentMutableConfig ignore)
EnvConfigObserverenvConfigUpdate in interface EnvConfigObserverpublic boolean isEnabled()
public boolean isEmpty()
public long getLastLocalId()
public long getLastReplicatedId()
public void setLastIds(long lastRepScanID,
long lastNonRepScanID)
public boolean isScanTaskActive(long id)
public void recoverIncompleteTasks()
executeRecoveredTasks(). If an extinction
is requested at the end of recovery (e.g., for temp DB deletion), it
is queued rather than being executed immediately.public void executeRecoveredTasks()
public void replay(byte[] scanKey,
byte[] scanData)
RecordExtinction#isTaskCommitted() assumes that the record is in the
Btree.public static long materializeKey(DatabaseEntry keyEntry)
public long discardExtinctRecords(@NonNull Locker locker, @NonNull Set<String> dbNames, @Nullable DatabaseEntry beginKey, @Nullable DatabaseEntry endKey, @Nullable ScanFilter filter, @NonNull String label)
isEnabled().DatabaseNotFoundException - if a DB name does not exist.public Set<Long> getCompletedRecordScans()
public void deleteCompletedRecordScans(Set<Long> scanIds)
getCompletedRecordScans().public void prepareForDbExtinction(ReplicationContext repContext)
startDbExtinction(com.sleepycat.je.dbi.DatabaseImpl)
will be called, i.e., for a DB remove/truncate operation. This method
ensures that the scan DB can be opened on the replica when replaying
the NameLN.
Returns without taking any action if this is a replica and the NameLN for the scan DB has not yet been replayed (the DB does not exist), and the truncate/remove operation itself is not replicated. See startDbExtinction for handling of this special case.
ReplicaWriteException - if this is a replica
node and the scan DB NameLN has not yet been replayed.public void startDbExtinction(DatabaseImpl dbImpl) throws DatabaseException
Note that the processing of the naming tree means the MapLN is never actually accessible from the current tree, but making the DB extinct is necessary to reclaim the memory and disk space it occupies.
This method initiates an async task to perform the following:
In one special case the task is executed synchronously (see below).
DatabaseExceptionpublic void ensureDbExtinction(DatabaseImpl dbImpl)
Copyright © 2024. All rights reserved.