Skip to content

tdfs4ds.process_store.followup_upgrade

tdfs4ds.process_store.followup_upgrade

FS_FOLLOW_UP: statistics and the opt-in primary index change (0.3.8.4).

Pure builders return SQL text and never run it; the few functions that write take an execute callable (default: execute_query with raise_error=True) so tests can record the order. Columns and view of the table never change, so older clients keep working.

logger module-attribute

logger = logging.getLogger(__name__)

STATISTICS_COLUMNS module-attribute

STATISTICS_COLUMNS = (('PROCESS_ID',), ('RUN_ID', 'PROCESS_ID'), ('START_DATETIME',), ('STATUS',))

STATISTICS_EVERY_SECONDS module-attribute

STATISTICS_EVERY_SECONDS = 6 * 3600

_LAST_STATISTICS module-attribute

_LAST_STATISTICS = {'at': None}

TARGET_PRIMARY_INDEX module-attribute

TARGET_PRIMARY_INDEX = 'PROCESS_ID'

RUNNING_REFUSAL_HOURS module-attribute

RUNNING_REFUSAL_HOURS = 1

COLUMNS module-attribute

COLUMNS = ('RUN_ID', 'PROCESS_TYPE', 'PROCESS_ID', 'START_DATETIME', 'END_DATETIME', 'VALIDTIME_DATE', 'APPLIED_FILTER', 'STATUS')

sql_literal

sql_literal(value)

Escape value for use inside a single-quoted SQL string literal.

For the DBC probes and catalog predicates that compare a name as data (WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.

_table

_table(suffix: str = '') -> str

_lit

_lit(value) -> str

follow_up_statistics_sql

follow_up_statistics_sql(table: str = None) -> list

The COLLECT STATISTICS statements for the follow-up table (base statistics options).

_default_execute

_default_execute(q)

collect_follow_up_statistics

collect_follow_up_statistics(execute=None) -> bool

Run the statements one by one. Fail-open: a failure is logged at DEBUG, never raised.

collect_follow_up_statistics_quietly

collect_follow_up_statistics_quietly(force: bool = False, execute=None) -> None

Throttled hook (once per STATISTICS_EVERY_SECONDS per Python process); never raises.

primary_index_sql

primary_index_sql() -> str

The read of the follow-up table's primary index columns (in order).

primary_index_is_target

primary_index_is_target(rows) -> bool

True when the index columns read are exactly PROCESS_ID.

running_rows_sql

running_rows_sql() -> str

new_table_ddl

new_table_ddl() -> str

The CREATE of <FS_FOLLOW_UP>_NEW: same columns as today's table, PRIMARY INDEX (PROCESS_ID).

copy_sql

copy_sql() -> str

_swap_sql

_swap_sql() -> list

_after_swap_sql

_after_swap_sql() -> list

migration_statements

migration_statements() -> list

The ordered statements of the change (dry-run text). Counts are verified between copy and swap.

_count

_count(rows) -> int

_exists

_exists(read, suffix: str) -> bool

apply_primary_index

apply_primary_index(read, execute, dry_run: bool = True) -> list

Do the change. read(sql) returns rows, execute(sql) runs a statement.

Refuses (RuntimeError) while a RUNNING row started within the last hour. The old table is kept as <FS_FOLLOW_UP>_OLD; a second call (index already right) drops it.