GitHub
08/30/2026, 10:46 AMbatch_wait_limit_seconds that sets the maximum time a batch can remain open before being processed, regardless of row count
• track batch start time in Sink._batch_start_time and reset it after each drain
• add Sink.is_too_old property to check elapsed time against the configured limit
• update Sink.is_full to trigger a drain when the time limit is exceeded
• drain expired batches at the start of record processing so batches that exceeded their limit while idle are handled before the next record
This addresses the case where a target runs in a memory-constrained environment and cannot afford to wait for large batches to fill up. The existing batch_size_rows setting controls the row count; this adds the complementary time-based control.
Validation
• uv run pytest -q — 859 passed, 388 deselected, 1 xfailed, 21 subtests passed
• mypy on changed files — passed
Files changed
• singer_sdk/helpers/capabilities.py — new TARGET_BATCH_WAIT_LIMIT_SECONDS_CONFIG
• singer_sdk/sinks/core.py — batch_wait_limit_seconds, _batch_start_time, is_too_old, updated is_full and mark_drained
• singer_sdk/target_base.py — import and merge new config in append_builtin_config, drain expired sinks at start of record processing
• tests/core/test_target_base.py — 10 new tests for config, is_too_old, is_full integration, drain reset, about info, negative values, expired batch drain, timer init
• tests/sql/test_target.py — added batch_wait_limit_seconds to expected default settings
Closes #1626
Summary by Sourcery
Add time-based batch draining for targets to prevent low-volume batches from remaining open indefinitely.
New Features:
• Add a configurable target-level time limit that processes open batches after they have waited too long, complementing row-count batch sizing.
Bug Fixes:
• Ensure expired batches are drained before processing a new record, including batches that expired while the target was idle.
Enhancements:
• Track batch lifetimes and reset the timer after each batch is drained.
• Expose the batch wait limit through target configuration and generated settings metadata, while ignoring negative values.
Tests:
• Add coverage for batch wait configuration, expiration behavior, drain integration, timer lifecycle, metadata exposure, and invalid values.
meltano/sdk