NAME

Langertha::Holmgang::Sim::Linux::MariaDB - MariaDB on a simulated Linux server — mysql/mariadb client, variables, users, binlogs, replica

VERSION

version 0.001

SYNOPSIS

# from the Linux simulator: mysql/mariadb, effect of starting/restarting the service
my ( $out, $ok ) = Langertha::Holmgang::Sim::Linux::MariaDB::client( $dev, \@argv, $ctx, $stdin, $os_user );
Langertha::Holmgang::Sim::Linux::MariaDB::service_event( $dev, 'restart' );

DESCRIPTION

A MariaDB server (Debian 12, MariaDB 10.11) on a device of type linux (cai-platform docs/entwurf-evals.md §3.3.1). The state lives under mariadb of the device, the option files under files, the service under services (name in mariadb.service):

mariadb:
  service:   mariadb
  conf:      [ /etc/mysql/mariadb.conf.d/50-server.cnf, /etc/mysql/mariadb.conf.d/90-tuning.cnf ]
  variables: { max_connections: "151", … }      # running values; without: from the files
  status:    { Threads_connected: 152, Max_used_connections: 152, … }
  users:     { "root@localhost": { auth: unix_socket }, "app@10.20.0.%": { password: secret, grants: [ "ALL PRIVILEGES ON `shop`.*" ] } }
  databases: [ shop ]
  processlist: [ { id: 1001, user: app, host: "10.20.0.21:41234", db: shop, command: Sleep, time: 12, count: 150 } ]
  binlogs:   [ { name: mariadb-bin.000410, size: 1073741824 }, … ]   # files under datadir with size
  replicas:  { db2: mariadb-bin.000412 }        # primary: binlog a replica is reading right now
  replica:   { master_host: 10.20.0.31, io: "Yes", sql: "No", last_errno: 1062, last_error: "…", skip: 1,
               behind: 14400, behind_parallel: 30 }   # lag; with slave_parallel_threads >= 2 after START
  tables:    { shop.orders: { columns: [ id, customer ], rows: [ [ 77120, K-1 ] ] } }   # read only

Client mysql/mariadb (-u, -p…/--password=…, -h, -P, -D, -e/--execute, -N, -B, -s, -t, -E, SQL on stdin; root via unix_socket when the caller is root), mysqladmin variables|status|processlist|ping|flush-privileges. SQL: SHOW [GLOBAL] VARIABLES|STATUS [LIKE …], SELECT @@[global.]var, …, SET [GLOBAL] var = value (dynamic ones only; otherwise error 1238), SHOW [FULL] PROCESSLIST, KILL id, SHOW DATABASES, SELECT … FROM mysql.user|mysql.db [WHERE …], SELECT 1, SELECT … FROM db.table [WHERE …] (only tables), SELECT … FROM information_schema.processlist [WHERE …] [ORDER BY …] [LIMIT n] (WHERE with =, LIKE, IN (…), numeric comparisons, IS [NOT] NULL, joined with AND), SHOW CREATE USER, SHOW GRANTS [FOR …], CREATE USER, DROP USER, ALTER USER … IDENTIFIED BY, GRANT/REVOKE (privileges on *.*, db.*, db.table), FLUSH PRIVILEGES|LOGS|BINARY LOGS, SHOW BINARY|MASTER LOGS, SHOW MASTER STATUS, PURGE BINARY|MASTER LOGS TO|BEFORE …, SHOW SLAVE|REPLICA STATUS, STOP|START SLAVE|REPLICA [IO_THREAD|SQL_THREAD], SET GLOBAL sql_slave_skip_counter = N, SET GLOBAL slave_parallel_threads|mode (only with the SQL thread stopped, otherwise 1198); terminated by ; or \G (vertical). Anything else is a gap in the simulation.

Effect: A start or restart reads the option files (sections [mysqld], [mariadb], [server], [mariadb-10.11]); an unknown variable or a wrong value prevents the start (conf_error). A restart ends all connections. When Threads_connected is as high as max_connections, only an account with SUPER (root) still gets a connection (error 1040). Deleting a binlog a replica is still reading (PURGE beyond it, or rm) breaks the replica (replicas).

Pure functions on the state, neutral.

parse_conf

my ( $values, $file, $line, $error ) = parse_conf( $dev );

Reads the server's option files (mariadb.conf) over the defaults: the variables (as SHOW VARIABLES shows them) or undef with file, line and error.

conf_error

my $lines = conf_error( $dev );   # undef or [ journal lines ]

service_event

service_event( $dev, 'start'|'restart'|'stop' );

file_removed

file_removed( $dev, $path );   # rm in the Linux simulator: binlog gone?

client

my ( $out, $ok ) = client( $dev, \@argv, $ctx, $stdin, $os_user, $prog );

mysqladmin

my ( $out, $ok ) = mysqladmin( $dev, \@argv, $ctx, $os_user );

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.