SickGrandma.ETSDumper (SickGrandma v0.1.0)
View SourceCore module responsible for ETS table discovery and data extraction.
Overview
ETSDumper handles the low-level operations of interacting with the ETS system,
including table discovery, metadata extraction, and data dumping. It implements
safe access patterns and graceful error handling for common ETS edge cases.
Design Philosophy
This module follows Elixir's "let it crash" philosophy for system-level failures while gracefully handling expected operational errors:
- System failures (ETS unavailable) → crash and let supervisor restart
- Operational errors (table deleted, access denied) → return error tuples
- Data safety → never modify tables, only read operations
Key Features
- Safe Discovery: Handles tables that disappear during enumeration
- Permission Handling: Respects table protection levels
- Metadata Extraction: Captures comprehensive table information
- Concurrent Safety: Handles tables modified during dumping
- Memory Efficiency: Processes tables individually to manage memory usage
Table Access Patterns
The module handles different ETS table protection levels:
- Public: Full read access to data and metadata
- Protected: Read access if owned by current process or inherited
- Private: Metadata only, data access denied
Error Recovery
Common scenarios handled gracefully:
- Tables deleted between discovery and access
- Permission changes during operation
- Concurrent modifications to table structure
- Large tables that might cause memory pressure
Internal Architecture
The module uses a pipeline approach:
- Discovery →
discover_tables/0 - Metadata →
get_table_info/1 - Data Extraction →
dump_single_table/1 - Safety Checks →
safe_tab2list/1
See Also
SickGrandma- Main API moduleSickGrandma.Logger- Output formatting and file operations
Summary
Functions
Discovers all ETS tables currently running in the system.
Dumps data from a single ETS table by name or ID.
Dumps data from multiple ETS tables.
Types
@type dump_data() :: %{ timestamp: DateTime.t(), total_tables: non_neg_integer(), tables: [table_info()] }
@type table_info() :: SickGrandma.table_info()
Functions
@spec discover_tables() :: {:ok, [table_info()]}
Discovers all ETS tables currently running in the system.
Returns {:ok, tables} where tables is a list of table info maps.
Will crash if ETS system is unavailable (which indicates a serious system issue).
@spec dump_table(atom() | integer()) :: {:ok, table_info()} | {:error, :table_not_found}
Dumps data from a single ETS table by name or ID.
Returns {:ok, table_data} or {:error, :table_not_found}.
Will crash if ETS system is unavailable.
@spec dump_tables([table_info()]) :: {:ok, dump_data()}
Dumps data from multiple ETS tables.
Returns {:ok, dump_data} where dump_data contains all table information.
Will crash if basic operations fail (indicating system issues).