synology_apm_repo.sdk.storage.generations module¶
S3/Azure db/<name>.<N> generation selection (FORMAT-SPEC.md:
Multi-generation selection). The single place this rule lives;
dedup/repository.py uses it for db/<name> and repo_info.
The naive “largest .<N> suffix” rule (resolve_seq_file) is not enough
here: a db/<name> generation can be written to S3/Azure before its
transaction commits, so the largest suffix can be uncommitted or superseded.
The answer needs the transaction log:
``latest_txn`` (
latest_transaction_id): the largestrepo_transactions/repo_transaction.<N>filename, opened and parsed — the answer is that file’s embeddedtransaction_id, never the filename’s own<N>(the two are not the same number).``file_map``/``repo_info`` (anything not in
SUPPLEMENTAL_TABLES): amongdb/<name>.<N>’s suffixes, the largest one strictly less thanlatest_txn— a generation written at or after the latest committed transaction is exactly the “written but not yet committed” case above.The 9 supplemental tables (
SUPPLEMENTAL_TABLES) use an independent, simpler rule: the largest suffix that also has a matchingsuppl_transaction_ids/<N>marker file — a numbering completely unrelated torepo_transactions/’s own.
A logical name with no .<N> variant falls back to the bare name.
- synology_apm_repo.sdk.storage.generations.SUPPLEMENTAL_TABLES = frozenset({'agent_connection', 'connection_config', 'copy_file', 'copy_source_version', 'copy_target_file', 'copy_target_version', 'copy_target_version_meta', 'file_meta', 'workload_config'})¶
The supplemental tables, resolved by the
suppl_transaction_ids/marker rule, not the transaction-log rule (FORMAT-SPEC.md: Multi-generation selection).copy_target_fileis listed for completeness; it sharescopy_target_version’s physical file (seePHYSICAL_NAME_ALIASES).
- synology_apm_repo.sdk.storage.generations.PHYSICAL_NAME_ALIASES: dict[str, str] = {'copy_target_file': 'copy_target_version'}¶
Logical
db/<name>names with no on-disk object of their own:copy_target_filelives inside thecopy_target_version[.N]file.DedupRepo.dbapplies it before generation resolution, on both layouts.
- synology_apm_repo.sdk.storage.generations.Listdir¶
A function returning a directory’s entry names, such as
DirCache.listdir.
- async synology_apm_repo.sdk.storage.generations.latest_transaction_id(store, transactions_dir, *, listdir=None)¶
The latest committed transaction id, per FORMAT-SPEC.md: Multi-generation selection: the
transaction_idembedded in the highest-numberedrepo_transaction.<N>file.- Parameters:
- Raises:
NotFoundError –
transactions_dirholds norepo_transaction.<N>.DataCorruptError – That file is corrupt (see
parse_repo_transaction).
- async synology_apm_repo.sdk.storage.generations.resolve_generation(store, db_dir, name, *, transactions_dir, suppl_dir, listdir=None)¶
The correct
db/<name>[.<N>]logical path fornameon anOBJECT_STORElayout: the largest.<N>strictly less than the latest committed transaction for most tables, or the largest.<N>with a matchingsuppl_transaction_idsmarker for the 9 supplemental tables (FORMAT-SPEC.md: Multi-generation selection). A name with no.<N>variant resolves to the bare name.- Parameters:
store (ObjectStore) – The repository’s store.
db_dir (str) – The
dbdirectory, joined withlayout.repo_root.name (str) – Logical
db/<name>.transactions_dir (str) –
repo_transactionsdirectory, likewise joined.suppl_dir (str) –
suppl_transaction_idsdirectory, likewise joined.listdir (Callable[[str], Awaitable[list[str]]] | None) – How to list the three directories; defaults to listing
storedirectly (pass aDirCache.listdirto share listings across the severaldb/<name>resolutions one repository does).
- Returns:
The store-relative path of the chosen generation.
- Raises:
NotFoundError –
.<N>variants exist but none is valid under the applicable rule (an inconsistent or partial repository copy), ortransactions_dirholds norepo_transaction.<N>.DataCorruptError – The latest
repo_transaction.<N>is corrupt.
- Return type: