WMCore Database Schema - Database schema definitions for WMCore components
Project description
WMCore Database Schema
Database schema definitions for WMCore components, including both MariaDB and Oracle backends.
WMBS (Workload Management Bookkeeping Service) provides the database schema for managing workloads and jobs.
Python Package
This repository is also available as a Python package on PyPI:
pip install wmcoredb
Usage
This is a data-only package that provides SQL schema files. After installation, the SQL files are available in the package data directory.
To access the SQL files programmatically:
import pkg_resources
# List all SQL files in the package
sql_files = pkg_resources.resource_listdir('wmcoredb', 'sql')
# Get the path to a specific SQL file
file_path = pkg_resources.resource_filename('wmcoredb', 'sql/mariadb/wmbs/create_wmbs_tables.sql')
# Read the SQL content
with open(file_path, 'r') as f:
sql_content = f.read()
Development
For local development and testing:
# Build the package
python -m build
# Install locally for testing
pip install dist/wmcoredb-*.whl
CI/CD Pipeline
The continuous integration pipeline is split into three workflows:
SQL Linting
Validates SQL syntax and formatting using SQLFluff:
- MariaDB files using default SQLFluff rules
- Oracle files using custom rules defined in
.sqlfluff.oracle - Enforces consistent SQL style and formatting
- Runs on every push and pull request
MariaDB Schema Validation
Automatically tests schema deployment in MariaDB:
- Runs only after successful linting
- Tests against multiple MariaDB versions:
- 10.6 (LTS)
- 10.11 (LTS)
- 11.4 (Latest)
- Deploys and validates:
- TestDB Schema
- WMBS Schema
- Agent Schema
- DBS3Buffer Schema
- BossAir Schema
- ResourceControl Schema
- Verifies table structures and relationships
- Checks for any critical database errors
Oracle Schema Validation
Tests schema deployment in Oracle:
- Runs only after successful linting
- Uses Oracle XE 18.4.0-slim container
- Deploys and validates the same schemas as the MariaDB workflow:
- TestDB Schema
- WMBS Schema (tables, indexes, and initial data)
- Tier0 Schema (tables, indexes, functions, and initial data)
- Agent Schema
- DBS3Buffer Schema
- BossAir Schema
- ResourceControl Schema
- Comprehensive verification steps:
- Table structure validation
- Index creation and type verification
- Foreign key relationship checks
- Initial data population verification
- Cross-database compatibility with MariaDB
- Includes proper error handling and cleanup procedures
- Uses SQL*Plus for schema deployment and verification
Directory Structure
The database schema files are organized as follows:
project_root/
├── src/
│ └── sql/ # Database schema files
│ ├── oracle/ # Oracle-specific SQL files
│ │ ├── wmbs/ # WMBS schema definitions
│ │ │ ├── create_wmbs_tables.sql # Table definitions with constraints
│ │ │ ├── create_wmbs_indexes.sql # Index definitions
│ │ │ └── initial_wmbs_data.sql # Static data for some tables
│ │ ├── agent/ # WMCore.Agent.Database schema
│ │ ├── bossair/ # WMCore.BossAir schema
│ │ ├── dbs3buffer/ # WMComponent.DBS3Buffer schema
│ │ ├── resourcecontrol/ # WMCore.ResourceControl schema
│ │ ├── testdb/ # WMQuality.TestDB schema
│ │ └── tier0/ # Tier0 schema definitions
│ │ ├── create_tier0_tables.sql # Table definitions with constraints
│ │ ├── create_tier0_indexes.sql # Index definitions
│ │ ├── create_tier0_functions.sql # Helper functions
│ │ └── initial_tier0_data.sql # Initial data for Tier0 tables
│ └── mariadb/ # MariaDB-specific SQL files
│ ├── wmbs/ # WMBS schema definitions
│ │ ├── create_wmbs_tables.sql # Table definitions with constraints
│ │ ├── create_wmbs_indexes.sql # Index definitions
│ │ └── initial_wmbs_data.sql # Static data for some tables
│ ├── agent/ # WMCore.Agent.Database schema
│ ├── bossair/ # WMCore.BossAir schema
│ ├── dbs3buffer/ # WMComponent.DBS3Buffer schema
│ ├── resourcecontrol/ # WMCore.ResourceControl schema
│ ├── testdb/ # WMQuality.TestDB schema
│ └── tier0/ # Tier0 schema definitions (NOT IMPLEMENTED)
└── src/python/ # Schema generation code (not included in package)
└── db/ # Legacy schema generation code
├── wmbs/
├── agent/
├── bossair/
├── dbs3buffer/
├── resourcecontrol/
└── testdb/
└── execute_wmbs_sql.py
Schema Components
The WMAgent database schema consists of several components:
-
WMBS (
src/sql/{oracle,mariadb}/wmbs/)- Core workload and job management
- Tables for jobs, subscriptions, and file tracking
- Initial data for job states and subscription types
-
Agent Database (
src/sql/{oracle,mariadb}/agent/)- Core agent functionality
- Component and worker management
-
BossAir (
src/sql/{oracle,mariadb}/bossair/)- Job submission and tracking
- Grid and batch system integration
-
DBS3Buffer (
src/sql/{oracle,mariadb}/dbs3buffer/)- Dataset and file management
- Checksum and location tracking
-
ResourceControl (
src/sql/{oracle,mariadb}/resourcecontrol/)- Site and resource management
- Threshold control
-
Test Database (
src/sql/{oracle,mariadb}/testdb/)- Simple test tables for database validation
- Used for testing database connectivity and basic operations
- Includes tables with different data types and constraints
- Available for both Oracle and MariaDB backends
-
Tier0 Schema (
src/sql/{oracle,mariadb}/tier0/)- Run management and tracking
- Stream and dataset associations
- Lumi section processing
- Configuration management
- Workflow monitoring
WMBS Schema Initialization
The WMBS schema is initialized first and consists of three files:
src/sql/{oracle,mariadb}/wmbs/
├── create_wmbs_tables.sql # Core WMBS tables
├── create_wmbs_indexes.sql # Indexes for performance
└── initial_wmbs_data.sql # Initial data for job states
These files are executed in order by execute_wmbs_sql.py to set up the base WMBS schema before other components are initialized.
Database Backend Support
The schema supports two database backends:
-
Oracle (
src/sql/oracle/)- Uses
NUMBER(11)for integers - Uses
VARCHAR2for strings - Uses
GENERATED BY DEFAULT AS IDENTITYfor auto-increment - Includes sequences and functions where needed
- Uses slash (/) as statement terminator for DDL statements (CREATE TABLE, CREATE INDEX)
- Uses both semicolon (;) and slash (/) for PL/SQL blocks (functions, procedures, packages)
- Semicolon terminates the PL/SQL block
- Slash executes the block
- Uses
-
MariaDB (
src/sql/mariadb/)- Uses
INTfor integers - Uses
VARCHARfor strings - Uses
AUTO_INCREMENTfor auto-increment - Uses
ENGINE=InnoDB ROW_FORMAT=DYNAMIC - Includes equivalent functionality without sequences
- Uses
Database Compatibility
The SQL files are designed to be compatible with:
MariaDB
- 10.6 (LTS)
- 10.11 (LTS)
- 11.4 (Latest)
Oracle
- Oracle XE 18.4.0-slim container
- Oracle 19c
The CI pipeline automatically tests schema deployment against these versions to ensure compatibility.
Database Documentation
For detailed database documentation, including Entity Relationship Diagrams (ERD), schema initialization flows, and module-specific diagrams, please refer to the diagrams documentation.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
Usage
To create the database schema:
- For Oracle:
@src/sql/oracle/testdb/create_testdb.sql
@src/sql/oracle/tier0/create_tier0_tables.sql
@src/sql/oracle/tier0/create_tier0_indexes.sql
@src/sql/oracle/tier0/create_tier0_functions.sql
@src/sql/oracle/tier0/initial_tier0_data.sql
@src/sql/oracle/wmbs/create_wmbs_tables.sql
@src/sql/oracle/wmbs/create_wmbs_indexes.sql
@src/sql/oracle/wmbs/initial_wmbs_data.sql
- For MariaDB:
source src/sql/mariadb/testdb/create_testdb.sql
source src/sql/mariadb/tier0/create_tier0_tables.sql
source src/sql/mariadb/tier0/create_tier0_indexes.sql
source src/sql/mariadb/tier0/create_tier0_functions.sql
source src/sql/mariadb/tier0/initial_tier0_data.sql
source src/sql/mariadb/wmbs/create_wmbs_tables.sql
source src/sql/mariadb/wmbs/create_wmbs_indexes.sql
source src/sql/mariadb/wmbs/initial_wmbs_data.sql
Schema Generation
The SQL schema files are generated from Python code in src/python/db/ (not included in the package). Each component has its own schema generation code:
from WMCore.Database.DBCreator import DBCreator
class Create(DBCreator):
def __init__(self, logger=None, dbi=None, params=None):
# Schema definition in Python
The schema files can be executed using execute_wmbs_sql.py, which handles:
- Database backend detection
- Schema file location
- Transaction management
- Error handling
Note: The schema generation code in src/python/db/ is for reference only and is not included in the PyPI package. The package only contains the final SQL files in src/sql/.
Logs
Some relevant logs from the WMAgent 2.3.9.2 installation:
Start: Performing init_agent
init_agent: triggered.
Initializing WMAgent...
init_wmagent: MYSQL database: wmagent has been created
DEBUG:root:Log file ready
DEBUG:root:Using SQLAlchemy v.1.4.54
INFO:root:Instantiating base WM DBInterface
DEBUG:root:Tables for WMCore.WMBS created
DEBUG:root:Tables for WMCore.Agent.Database created
DEBUG:root:Tables for WMComponent.DBS3Buffer created
DEBUG:root:Tables for WMCore.BossAir created
DEBUG:root:Tables for WMCore.ResourceControl created
checking default database connection
default database connection tested
...
_sql_write_agentid: Preserving the current WMA_BUILD_ID and HostName at database: wmagent.
_sql_write_agentid: Creating wma_init table at database: wmagent
_sql_write_agentid: Inserting current Agent's build id and hostname at database: wmagent
_sql_dumpSchema: Dumping the current SQL schema of database: wmagent to /data/srv/wmagent/2.3.9/config/.wmaSchemaFile.sql
Done: Performing init_agent
WMAgent DB Initialization
It starts in the CMSKubernetes init.sh script, which executes init_agent() method from the CMSKubernetes manage script.
The database optios are enriched dependent on the database flavor, such as:
case $AGENT_FLAVOR in
'mysql')
_exec_mysql "create database if not exists $wmaDBName"
local database_options="--mysql_url=mysql://$MDB_USER:$MDB_PASS@$MDB_HOST/$wmaDBName "
'oracle')
local database_options="--coredb_url=oracle://$ORACLE_USER:$ORACLE_PASS@$ORACLE_TNS "
It then executes WMCore code, calling a script called wmagent-mod-config.
with command line arguments like:
wmagent-mod-config $database_options \
--input=$WMA_CONFIG_DIR/config-template.py \
--output=$WMA_CONFIG_DIR/config.py \
which internally parses the command line arguments into parameters and modifies the standard WMAgentConfig.py, saving it out as the new WMAgent configuration file, with something like:
cfg = modifyConfiguration(cfg, **parameters)
saveConfiguration(cfg, outputFile)
With the WMAgent configuration file properly updated, named config.py, now the manage script calls wmcore-db-init, with arguments like:
wmcore-db-init --config $WMA_CONFIG_DIR/config.py --create --modules=WMCore.WMBS,WMCore.Agent.Database,WMComponent.DBS3Buffer,WMCore.BossAir,WMCore.ResourceControl;
This wmcore-db-init script itself calls the WMInit.py script, executing basically the next four commands:
wmInit = WMInit()
wmInit.setLogging('wmcoreD', 'wmcoreD', logExists = False, logLevel = logging.DEBUG)
wmInit.setDatabaseConnection(dbConfig=config.CoreDatabase.connectUrl, dialect=dialect, socketLoc = socket)
wmInit.setSchema(modules, params = params)
In summary, the WMAgent database schema is an aggregation of the schema defined under each of the following WMAgent python directories:
WMCore.WMBS --> originally under src/python/db/wmbs
WMCore.Agent.Database --> originally under src/python/db/agent
WMCore.BossAir --> originally under src/python/db/bossair
WMCore.ResourceControl --> originally under src/python/db/resourcecontrol
WMComponent.DBS3Buffer --> originally under src/python/db/dbs3buffer
The wmcore-db-init script itself calls the WMInit.py script, executing basically the next four commands:
wmInit = WMInit()
wmInit.setLogging('wmcoreD', 'wmcoreD', logExists = False, logLevel = logging.DEBUG)
Tier0 Schema
The Tier0 schema is designed to support the Tier0 data processing system. It includes tables for:
- Run management and tracking
- Stream and dataset associations
- Lumi section processing
- Configuration management
- Workflow monitoring
Oracle Implementation
The Oracle implementation uses modern features like:
- IDENTITY columns for auto-incrementing IDs
- Inline foreign key constraints
- Organization index tables for performance
- Deterministic functions for state validation
The schema initialization includes:
- Table definitions with constraints
- Index definitions for performance
- Helper functions for state validation
- Initial data for run states, processing styles, and event scenarios
MariaDB Implementation
Tier0 system does not - yet - support multiple database backends. For the moment, we have not converted the Tier0 schema to be compliant with MariaDB/MySQL.
Test Database Schema
The Test Database schema provides a simple set of tables for testing database connectivity and basic operations. It includes:
- Tables with different data types (INT, VARCHAR, DECIMAL)
- Primary key constraints
- Table and column comments
- Cross-database compatibility
Oracle Implementation
The Oracle implementation uses:
- NUMBER for numeric columns
- VARCHAR2 for string columns
- Table and column comments
- Primary key constraints
MariaDB Implementation
The MariaDB implementation provides equivalent functionality using:
- INT and DECIMAL for numeric columns
- VARCHAR for string columns
- InnoDB engine specification
- Compatible comment syntax
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wmcoredb-0.8.5.tar.gz.
File metadata
- Download URL: wmcoredb-0.8.5.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94312f84bcf30e2434eb0579b9e7303c23c8fb2fc165f1a47dd450a2d294aa37
|
|
| MD5 |
9316772152e0c4221d0e69af59d4256b
|
|
| BLAKE2b-256 |
a79192469cc6e001539b2e3cc141b4ede15058c55567882313c415e19a77d8ef
|
Provenance
The following attestation bundles were made for wmcoredb-0.8.5.tar.gz:
Publisher:
release.yml on dmwm/wmcoredb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wmcoredb-0.8.5.tar.gz -
Subject digest:
94312f84bcf30e2434eb0579b9e7303c23c8fb2fc165f1a47dd450a2d294aa37 - Sigstore transparency entry: 268426350
- Sigstore integration time:
-
Permalink:
dmwm/wmcoredb@f48f24191c68e92f23cfd8d9ddfc17ed2fc6c20b -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/dmwm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f48f24191c68e92f23cfd8d9ddfc17ed2fc6c20b -
Trigger Event:
push
-
Statement type:
File details
Details for the file wmcoredb-0.8.5-py3-none-any.whl.
File metadata
- Download URL: wmcoredb-0.8.5-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8715c67471f8170a9e65ca827c025af54688c15fcf010aaffd6c07737216146c
|
|
| MD5 |
f2e9fd30a3627c810d7dba27dcbfe8c5
|
|
| BLAKE2b-256 |
d0f5281d24d550cd225ccf4a6d6a270794f30b600578757226b3c76abc14d896
|
Provenance
The following attestation bundles were made for wmcoredb-0.8.5-py3-none-any.whl:
Publisher:
release.yml on dmwm/wmcoredb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wmcoredb-0.8.5-py3-none-any.whl -
Subject digest:
8715c67471f8170a9e65ca827c025af54688c15fcf010aaffd6c07737216146c - Sigstore transparency entry: 268426357
- Sigstore integration time:
-
Permalink:
dmwm/wmcoredb@f48f24191c68e92f23cfd8d9ddfc17ed2fc6c20b -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/dmwm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f48f24191c68e92f23cfd8d9ddfc17ed2fc6c20b -
Trigger Event:
push
-
Statement type: