# luizsilvadba/db2_parallel_load architecture

> Architecture diagram of the GitHub repository luizsilvadba/db2_parallel_load, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luizsilvadba/db2_parallel_load
- Repository: https://github.com/luizsilvadba/db2_parallel_load

## Overview

#### Purpose and Entry Point
This repository is a DB2 bulk-migration utility that runs multiple table loads concurrently. Its sole executable entry point is `parallel_load.sh`, invoked with source database, target database, and desired parallel-load count.

#### Orchestration Model
`parallel_load.sh` coordinates a bounded set of forked DB2 load processes. Workers claim pending migration records, execute independent source-to-target loads, and continue claiming work so available concurrency remains utilized while rows remain queued.

Paths:
- `parallel_load.sh`

#### Migration Work Queue and State
The target DB’s `MIGRATION.CONTROL_LOAD` table is the durable work queue and operational state store. Each row identifies source/target schema and table, optional source predicate, timing fields, DB2 load counters, and a worker/process identifier. State transitions distinguish pending, running, and completed loads.

The README provides the required DDL and monitoring queries; the table is external database infrastructure rather than a repository-managed schema artifact.

Paths:
- `README.md`
- `parallel_load.sh`

#### Source-to-Target Data Boundary
The script runs under the target DB2 instance identity, while the source database must be cataloged in that same DB2 instance directory. A worker reads a source table (optionally constrained by `SOURCE_FILTER`) and submits data to DB2’s target-side `LOAD` capability. Source and target tables normally require compatible, one-to-one column definitions.

Paths:
- `parallel_load.sh`
- `README.md`

#### Column Mapping Override
`MIGRATION.COLUMN_MAPPING` is an optional metadata layer for migrations where source and target columns do not align directly. It maps a source column expression to each target column, allowing the generated source selection to differ from the default same-column-list behavior.

Paths:
- `README.md`
- `parallel_load.sh`

#### Parallelism and Large Partitioned Tables
Parallelism is process-based, controlled by the final CLI argument rather than an application server or scheduler. Large range-partitioned source tables can be represented as multiple control rows with distinct partition-range filters, loaded into temporary target tables concurrently, then attached afterward through DB2 administration steps outside this script.

Paths:
- `parallel_load.sh`
- `README.md`

#### Operations and Observability
Progress is persisted in DB2 control-table timestamps, worker IDs, and row-level load statistics (`rows_read`, loaded, rejected, committed, etc.). Per-worker shell/DB2 output is written to files matching `*._parallel_load_from_*.out`, enabling live log tailing. `parallel_load.sh` is the only runtime artifact; execution depends on a DB2 CLI environment, cataloged source database, target database, and pre-created `MIGRATION` control tables.

Paths:
- `parallel_load.sh`
- `README.md`

Main entry points: [`parallel_load.sh`](https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh) (Forked load workers), [`README.md`](https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md) (Partitioned-table workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Shell Runtime"]
  node_cli(("CLI invocation<br/>command<br/>[parallel_load.sh]"))
  node_orchestrator["parallel_load.sh<br/>shell orchestrator<br/>[parallel_load.sh]"]
  node_workers["Forked load workers<br/>DB2 CLI processes<br/>[parallel_load.sh]"]
end

subgraph group_db2["DB2 Data Plane"]
  node_db2_env{{"Target DB2 instance<br/>execution environment"}}
  node_control_load[("MIGRATION.CONTROL_LOAD<br/>durable work queue")]
  node_column_mapping[("MIGRATION.COLUMN_MAPPING<br/>mapping metadata")]
  node_source_db[("Cataloged source database<br/>source DB2 database")]
  node_target_db[("Target database<br/>target DB2 database")]
  node_db2_load{{"DB2 LOAD<br/>bulk-load capability<br/>[parallel_load.sh]"}}
  node_partition_flow["Partitioned-table workflow<br/>external DB2 administration<br/>[README.md]"]
end

subgraph group_ops["Operations"]
  node_worker_logs["Per-worker output files<br/>runtime logs<br/>[parallel_load.sh]"]
  node_monitoring["Progress monitoring<br/>operational queries<br/>[README.md]"]
  node_runbook["DDL and runbook<br/>documentation<br/>[README.md]"]
end

node_cli -->|"invokes"| node_orchestrator
node_orchestrator -->|"forks up to requested count"| node_workers
node_orchestrator -->|"runs under"| node_db2_env
node_workers -->|"claim pending work; update state"| node_control_load
node_workers -.->|"reads when present"| node_column_mapping
node_workers -->|"selects source rows"| node_source_db
node_workers -->|"submits selected data"| node_db2_load
node_db2_load -->|"bulk loads target table"| node_target_db
node_db2_load -->|"records load counters and completion"| node_control_load
node_workers -->|"writes DB2 and shell output"| node_worker_logs
node_monitoring -->|"queries progress"| node_control_load
node_runbook -.->|"documents required DDL"| node_control_load
node_source_db -.->|"range-filtered control rows"| node_partition_flow
node_partition_flow -.->|"attach temporary loads"| node_target_db

click node_cli "https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh"
click node_orchestrator "https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh"
click node_workers "https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh"
click node_db2_load "https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh"
click node_partition_flow "https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md"
click node_worker_logs "https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh"
click node_monitoring "https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md"
click node_runbook "https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_orchestrator,node_workers toneBlue
class node_db2_env,node_control_load,node_column_mapping,node_source_db,node_target_db,node_db2_load,node_partition_flow toneAmber
class node_worker_logs,node_monitoring,node_runbook toneMint
```

## Components

### Shell Runtime

- [CLI invocation](https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh): command · Source DB, target DB, and worker-count arguments. · `parallel_load.sh`
- [parallel_load.sh](https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh): shell orchestrator · Bounds and replenishes forked load workers. · `parallel_load.sh`
- [Forked load workers](https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh): DB2 CLI processes · Each worker repeatedly claims and loads one migration row. · `parallel_load.sh`

### DB2 Data Plane

- **Target DB2 instance**: execution environment · Must catalog the source database under the target instance identity.
- **MIGRATION.CONTROL_LOAD**: durable work queue · Stores migration definition, state, worker ID, timing, and load counters.
- **MIGRATION.COLUMN_MAPPING**: mapping metadata · Optional source-expression to target-column overrides.
- **Cataloged source database**: source DB2 database · Provides source tables and optional row filters.
- **Target database**: target DB2 database · Receives table loads and hosts migration metadata.
- [DB2 LOAD](https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh): bulk-load capability · Loads selected source data into target tables. · `parallel_load.sh`
- [Partitioned-table workflow](https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md): external DB2 administration · Concurrent temporary-table loads can be attached afterward outside the script. · `README.md`

### Operations

- [Per-worker output files](https://github.com/luizsilvadba/db2_parallel_load/blob/master/parallel_load.sh): runtime logs · Files match *._parallel_load_from_*.out for live tailing. · `parallel_load.sh`
- [Progress monitoring](https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md): operational queries · Reads timestamps, worker IDs, and row-level load statistics. · `README.md`
- [DDL and runbook](https://github.com/luizsilvadba/db2_parallel_load/blob/master/README.md): documentation · Defines required migration tables and operating guidance. · `README.md`

## Connections

- CLI invocation → parallel_load.sh: invokes
- parallel_load.sh → Forked load workers: forks up to requested count
- parallel_load.sh → Target DB2 instance: runs under
- Forked load workers → MIGRATION.CONTROL_LOAD: claim pending work; update state
- Forked load workers → MIGRATION.COLUMN_MAPPING: reads when present
- Forked load workers → Cataloged source database: selects source rows
- Forked load workers → DB2 LOAD: submits selected data
- DB2 LOAD → Target database: bulk loads target table
- DB2 LOAD → MIGRATION.CONTROL_LOAD: records load counters and completion
- Forked load workers → Per-worker output files: writes DB2 and shell output
- Progress monitoring → MIGRATION.CONTROL_LOAD: queries progress
- DDL and runbook → MIGRATION.CONTROL_LOAD: documents required DDL
- Cataloged source database → Partitioned-table workflow: range-filtered control rows
- Partitioned-table workflow → Target database: attach temporary loads
