Skip to content

[Test][E2E] Stabilize DB2 upsert timestamp ordering#11161

Closed
davidzollo wants to merge 2 commits into
apache:devfrom
DanielLeens:dev-db2-upsert-order-20260622
Closed

[Test][E2E] Stabilize DB2 upsert timestamp ordering#11161
davidzollo wants to merge 2 commits into
apache:devfrom
DanielLeens:dev-db2-upsert-order-20260622

Conversation

@davidzollo

Copy link
Copy Markdown
Contributor

Why

What

  • add ORDER BY C_INT to the DB2 verification queries in JdbcDb2UpsertIT
  • keep the original timestamp assertions unchanged and only stabilize the result ordering by the integer primary key

Validation

  • ./mvnw spotless:apply
  • ./mvnw -pl seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-common,seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-1 -DskipTests test-compile
  • attempted real E2E path with ./mvnw -pl seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-common,seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-1 -Dtest=JdbcDb2UpsertIT -Dsurefire.failIfNoSpecifiedTests=false test

Validation notes

  • seatunnel-engine-ui was not built because this change only touches JDBC E2E tests
  • the local E2E reached the real DB2 container startup and test bootstrap, but the run is still blocked by missing prebuilt starter jars in the local environment, so full end-to-end completion could not be finished on this machine

davidzollo and others added 2 commits February 1, 2026 22:36
This PR introduces a comprehensive data tracing system for SeaTunnel Engine
that tracks sampled records through the entire pipeline with minimal overhead.

## Core Features

### Trace Infrastructure
- StainTraceEvent: Event system for trace points
- StainTracePayload: Compact binary payload (STTR protocol v1)
- StainTraceSampler: Deterministic sampling (seq % rate == 0)
- StainTraceBudget: Per-worker per-second budget control
- TaskMappingBuilder: Maps task IDs to human-readable names

### Trace Stages (6 stages)
1. SOURCE_EMIT: Source emits record
2. QUEUE_IN: Queue enqueue complete
3. QUEUE_OUT: Queue dequeue start
4. TRANSFORM_IN: Transform receives record
5. TRANSFORM_OUT: Transform outputs record
6. SINK_WRITE_DONE: Sink write complete

### Framework Integration (Zero connector changes)
- RecordSerializer: Extended for payload transmission (backward compatible)
- SeaTunnelSourceCollector: Create payload, append SOURCE_EMIT
- IntermediateQueue: Append QUEUE_IN/QUEUE_OUT
- TransformFlowLifeCycle: Append TRANSFORM_IN/OUT (handles 1-to-N)
- SinkFlowLifeCycle: Append SINK_WRITE_DONE, report event

### Trace Collector Service
Standalone HTTP service for collecting and querying traces:
- Multi-database support: PostgreSQL, MySQL, ClickHouse
- REST APIs: /ingest, /traces, /trace/{id}, /health, /metrics
- Task mapping cache: Auto-fetch task names from Engine
- Payload decoder: Parse binary payload to timing entries
- Built-in metrics: Ingestion rate, errors, query latency

### Web UI Integration
- New trace visualization page
- Query by trace_id or job_id
- Display timing breakdown per stage
- Visualize bottlenecks

### Configuration
```yaml
seatunnel:
  engine:
    stain-trace-enabled: true
    stain-trace-sample-rate: 100000
    stain-trace-max-traces-per-second-per-worker: 50
    stain-trace-max-entries-per-trace: 32
```

### Production Safety
- Zero overhead when disabled (single boolean check)
- ~0.1-1% overhead with 1% sampling when enabled
- Strict event volume upper bound (per-worker budget)
- One event per sampled record (no event storm)
- Backward compatible serialization (new reads old)

## Implementation Details

### Binary Payload Protocol
```
MAGIC(4)  = 0x53545452  // 'STTR'
VER(2)    = 1
TRACE_ID(8)
START_TS_MS(8)
COUNT(2)
ENTRIES:
  STAGE(1), TASK_ID(8), TS_MS(8)
```

### Performance Analysis
From trace entries, calculate:
- End-to-end latency: SINK_WRITE_DONE.ts - SOURCE_EMIT.ts
- Queue wait time: QUEUE_OUT.ts - QUEUE_IN.ts
- Transform processing: TRANSFORM_OUT.ts - TRANSFORM_IN.ts
- Sink write time: SINK_WRITE_DONE.ts - TRANSFORM_OUT.ts

Aggregate P95/P99 metrics to identify bottlenecks.

## Testing
- Unit tests: StainTracePayloadTest, StainTraceSamplerTest, RecordSerializerTest
- Integration tests: StainTraceFlowIT, TransformFlowLifeCycleStainTraceTest
- Backward compatibility: Old format → new reader
- Edge cases: 1-to-N (FlatMap), 1-to-0 (Filter), checkpoint recovery

## Documentation
- Quick start guide: seatunnel-trace/STAIN_TRACE_QUICKSTART.md
- Database init scripts: init-mysql.sql, etc.
- Config reference and deployment guide

## Files Changed
82 files changed, 6612 insertions(+), 42 deletions(-)
@davidzollo

Copy link
Copy Markdown
Contributor Author

Closing this accidental fork-base PR. The DB2 ordering fix is already present in current apache/dev, and PR #11137 has been updated to latest dev so its rerun can pick up that baseline fix.

@davidzollo davidzollo closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants