UDFs do not seem to propagate Watermarks
Describe the bug UDFs created with this library do not seem to pass on watermarks to subsequent stages in the pipeline; this effectively makes Reduce components impossible to implement in anything but a simple pipeline
e.g: _event_time=datetime.datetime(2026, 3, 5, 17, 6, 34, 563000), _watermark=datetime.datetime(1969, 12, 31, 23, 59, 59, 999000), _headers={})
To Reproduce Steps to reproduce the behavior:
- Create a simple pipeline which has a source, map udf, reduce udf, and a sink
- Log datums coming into the reduce UDF
- Check the numaflow UI
- Notice watermarks are set between source and map UDF
- Notice watermarks are not set between map UDF and reduce UDF
- Notice logged datums coming into reduce UDF have a set
_event_timebut_watermarkis effectively set to -1
Expected behavior Watermarks are propagated through UDFs
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- Kubernetes: v1.32.2
- Numaflow: v1.4.2 (also v1.7.3)
- Numaflow-python: 0.10.1 (also 0.12.1)
Message from the maintainers:
Impacted by this bug? Give it a 👍. We often sort issues this way to know what to prioritize.
Do you mind sharing the pipeline spec? I would like to know what windowing you are using.
Notice logged datums coming into reduce UDF have a set _event_time but _watermark is effectively set to -1
This is the correct behavior if watermark is not moving. The question should be why is watermark not moving.
Hi @vigith thanks for the reply
Ideally I'd like to use a session window but I assume that's not supported (no note here: https://numaflow.numaproj.io/user-guide/user-defined-functions/reduce/windowing/session/ ). I've tried:
- Session with timeout 3m
- Sliding length 60s, slide 10s
- Fixed with length 60s
All with streaming and keyed set to true
The current instance I've been testing:
- name: [...]
partitions: 1
limits:
readBatchSize: 1
udf:
container:
args:
- python
- src/[...]
image: localhost:5000/[...]
imagePullPolicy: Always
groupBy:
window:
sliding:
length: 60s
slide: 10s
streaming: true
keyed: true
storage:
persistentVolumeClaim:
volumeSize: 1Gi
accessMode: ReadWriteOncePod
and with a simple class inheriting from ReduceStreamer (code redacted, debug statements added):
async def handler(
self,
keys: list[str],
datums: AsyncIterable[Datum],
output: NonBlockingIterator,
md: Metadata
):
print(md.interval_window.start)
async for datum in datums:
print(datum)
[...]
print("loop finished")
for out in final_out:
await output.put(Message(str.encode(out), keys=[keys], tags=['...']))
I'm seeing the first two print statements (interval start, datum), but never the "loop finished" statement - this is what's led me to conclude there seems to be a problem with the windowing itself, as I understand that final statement is where the accumulated output should be returning
Please do let me know if any of those are flawed assumptions; this is the best I could figure out from examples and documentation
@niall-nai could you please try out the latest 1.7.3 release?
@BulkBeing thanks for the quick work on this! Glad you could reproduce and solve
@vigith I can try upgrading everything yes
@vigith can confirm this happens @ 0.12.1 and 1.7.3 (updated original post)
We will try to reproduce this on our end /cc @BulkBeing
@niall-nai The fix in my PR is not yet released (only in main branch). I've pushed the code I used here https://github.com/BulkBeing/reproduce-issues/tree/main/numa-python-reduce-watermark Above code adds pynumaflow dependency as a git url .
In your setup:
# uv
uv add "pynumaflow @ git+https://github.com/numaproj/numaflow-python.git@b37f25fef9588a736a1e7957e1b61cc228d25f4e#subdirectory=packages/pynumaflow"
# or poetry
poetry add "git+https://github.com/numaproj/numaflow-python.git@b37f25fef9588a736a1e7957e1b61cc228d25f4e#subdirectory=packages/pynumaflow"
NOTE: The package is in a sub-directory.
If possible, can you reproduce the issue with the setup/code in the repo I linked and create a PR to that if any modifications are needed.
@BulkBeing so I have good news and bad news
The good news is that the reduce streamer is reaching the output stage with watermarks! Fantastically quick turnaround, thank you!
The bad news is that I'm getting the following:
TypeError: bad argument type for built-in operation
2026-03-11 15:25:04 CRITICAL Reduce Streaming Error: TypeError('bad argument type for built-in operation')
Traceback (most recent call last):
File "/opt/app-root/lib64/python3.12/site-packages/pynumaflow/reducestreamer/servicer/task_manager.py", line 256, in process_input_stream
await con_future
File "/opt/app-root/lib64/python3.12/site-packages/pynumaflow/reducestreamer/servicer/task_manager.py", line 288, in write_to_global_queue
res = reduce_pb2.ReduceResponse.Result(keys=msg.keys, value=msg.value, tags=msg.tags)
When calling:
for out in output:
msg_out = json.dumps(out, indent=4, default=str)
await output.put(Message(str(msg_out).encode(), keys=[keys], tags=['...']))
out in this case is a fairly straightforward object which converts into a string easily with json.dumps. Replacing with a debug string also yields the same response. Tried without tags as in your example above
Also just for my awareness- is it expected that the reducer container should "complete" in k8s? This is just for my understanding so I can tweak the pipeline correctly
I was able to reproduce this stacktrace. The problem is in:
output.put(Message(str(msg_out).encode(), keys=[keys], tags=['...']))
The type of the value passed to the keys parameter becomes list[list[str]] as the keys is already a list[str] https://github.com/BulkBeing/reproduce-issues/blob/cdcf7ed0d85995ac64b10e1a0199f91c5925e6fa/numa-python-reduce-watermark/main.py#L40
The TypeError: bad argument type for built-in operation is a generic protobuf error if any of the passed argument has wrong type.
I will create a PR for better error messages.
Also just for my awareness- is it expected that the reducer container should "complete" in k8s? This is just for my understanding so I can tweak the pipeline correctly
No, it's not expected — the reducer should remain running. The container completing/terminating is a side effect of the unhandled TypeError crashing the process.
@BulkBeing thanks so much for your help- with that I've now managed to get at least one run-through succesfully
Unfortunately I'm still seeing flakey behaviour wrt the watermark- one I set running around 1030 today reported -1:
_event_time=datetime.datetime(2026, 3, 12, 10, 33, 21, 729000), _watermark=datetime.datetime(1969, 12, 31, 23, 59, 59, 999000)
then when I came back to it around 1400:
_event_time=datetime.datetime(2026, 3, 12, 14, 12, 42, 502000), _watermark=datetime.datetime(2026, 3, 12, 10, 33, 21, 729000)
I ran through the pipeline again straight after that and:
_event_time=datetime.datetime(2026, 3, 12, 14, 14, 45, 414000), _watermark=datetime.datetime(2026, 3, 12, 14, 12, 42, 502000)
At which point the data was outputted as expected. It looks like the watermark is only being set on the completion of the previous run, and therefore you can only ever output the last run and only if you run two jobs one after the other? Still using the same pipeline setup as before
It looks like the watermark is only being set on the completion of the previous run
Could you please explain what you are trying to do? What does "previous run" mean?
It looks like the watermark is only being set on the completion of the previous run
Could you please explain what you are trying to do? What does "previous run" mean?
we're using numaflow as a data processing pipeline triggered by users - they upload a file, and it's processed then outputted onto a series of kafka topics and stored based on those. Currently we do this by a very simple "pipeline" that goes source->udf->sink and the current task is to break this out into source->n udfs->sink, which requires a reducer to aggregate data from across stages. By previous run, I mean the end-to-end upload->process
@niall-nai please let me know if you want to chat over slack? There are some caveats you should be aware of.
we're using numaflow as a data processing pipeline triggered by users - they upload a file, and it's processed then outputted onto a series of kafka topics and stored based on those. Currently we do this by a very simple "pipeline" that goes source->udf->sink and the current task is to break this out into source->n udfs->sink, which requires a reducer to aggregate data from across stages. By previous run, I mean the end-to-end upload->process
Thanks for explaining the use case. This helps clarify what's happening.
In Numaflow, watermarks are driven by data arrival - the watermark advances as new messages flow through the pipeline. When you do batch processing (upload a file, process it, then wait), once all the messages from that batch have been read and there's no new data coming in, the watermark effectively stalls because there's nothing arriving to push it forward. This is why you're seeing the watermark from the previous run being applied to the current one — the watermark only caught up when new data arrived.
For batch/on-demand workloads like yours, you'll want to enable source idleness on your pipeline. When idleness is enabled, if a source has no new data for a configured duration, Numaflow will mark it as idle and allow the watermark to advance past it. This ensures that after your batch is fully ingested, the watermark will still progress and your reduce windows will close and emit results as expected.
You can configure this on your source spec, e.g.:
source:
...
watermark:
idleSource:
threshold: 5s # mark source idle after 5s of no data
stepInterval: 2s # advance watermark by this increment when idle
incrementBy: 3s
Feel free to join us on Slack if you'd want to understand more.
@vigith thank you so much for your help! Looks like that's resolved it, seeing expected behaviour consistently now! Can't understate how helpful it's been to have quick, useful replies on this- I was almost expecting not to be able to resolve this for months. Both yourself and @BulkBeing, it's hugely appreciated
Unfortunately I can't join your Slack due to workplace policies but thanks for the offer all the same :)