feat: parallelize pgoutput WAL log processing #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements parallel WAL log processing for PostgreSQL CDC to improve throughput and reduce latency during change data capture operations.
The implementation uses transaction batching to maintain ACID properties while allowing independent transactions to be processed in parallel. A configurable worker pool processes changes concurrently, with each worker handling complete transactions sequentially to preserve ordering within transactions.
Fixes #553
Type of change
Implementation Details
Configuration: New optional
WALWorkerCountfield in PostgreSQL CDC config (defaults to 1 for backward compatibility)Architecture:
errgroupsync.RWMutexfor concurrent reads from multiple workersCode Changes:
pkg/waljs/pgoutput.go- Core parallel implementation (~300 lines added)pkg/waljs/types.go- AddedWorkerCountconfig fielddrivers/postgres/internal/config.go- AddedWALWorkerCountJSON fielddrivers/postgres/internal/cdc.go- Passed config through to waljspkg/waljs/pgoutput_test.go- 4 unit tests (all passing)How Has This Been Tested?
Benchmark Results
Performance measured with realistic workload (100µs processing per record):
Test Evidence
✓ Unit tests pass without database
✓ Integration tests pass with PostgreSQL (docker-compose)
✓ Data integrity verified: 1,000 records with zero duplicates/missing records
✓ Full codebase compiles:
go build ./...Documentation
Related PRs
None