Skip to content

Conversation

@Ludv1gL
Copy link

@Ludv1gL Ludv1gL commented Jan 1, 2026

Summary

This fixes a regression introduced in commit afe169a ("Fix the issues with scheduling procedures #3816", Dec 5, 2025) where scheduled reducers stopped recording their ReducerContext to the commitlog.

Impact:

  • No inputs section was written to the commitlog for scheduled reducers
  • The reducer's arguments and caller info were not persisted

Root Cause

The old code in module_host.rs::call_scheduled_reducer_inner patched tx.ctx with the ReducerContext:

tx.ctx = ExecutionContext::with_workload(
    tx.ctx.database_identity(),
    Workload::Reducer(ReducerContext { ... }),
);

This was removed when the logic moved to scheduler.rs. The new code in call_reducer_with_tx only applies the ReducerContext when tx is None — since the scheduler passes Some(tx), the context was never applied.

Fix

Restore the tx.ctx patching in scheduler.rs before calling call_reducer_with_tx.

This fixes a regression introduced in commit afe169a ("Fix the issues
with scheduling procedures clockworklabs#3816", Dec 5, 2025) where scheduled reducers
stopped recording their ReducerContext to the commitlog.

## Problem

When a scheduled reducer runs, the transaction was started with
`Workload::Internal`, and the code path that would patch it to
`Workload::Reducer(ReducerContext)` was removed during the refactor.

This meant that:
1. No `inputs` section was written to the commitlog for scheduled reducers
2. Temporal queries could not extract timestamps from scheduled reducer
   commits, returning 0 for all `__system_time__` values
3. The reducer's arguments and caller info were not persisted

## Root Cause

The old code in `module_host.rs::call_scheduled_reducer_inner` had:

```rust
tx.ctx = ExecutionContext::with_workload(
    tx.ctx.database_identity(),
    Workload::Reducer(ReducerContext { ... }),
);
```

This patching was removed when the logic was moved to `scheduler.rs`.
The new code in `call_reducer_with_tx` creates a ReducerContext but only
uses it when `tx` is `None` - since the scheduler passes `Some(tx)`,
the ReducerContext was never applied.

## Fix

Restore the `tx.ctx` patching in `scheduler.rs` before calling
`call_reducer_with_tx`, ensuring the ReducerContext is properly set
for scheduled reducers just as it was before the refactor.

## Testing

Verified with temporal-sensor-demo module:
- Before fix: `SELECT * FROM sensor_data ALL` returned `__system_time__: 0`
- After fix: Returns actual timestamps like `2025-12-21 01:42:51.113816`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Jan 1, 2026

CLA assistant check
All committers have signed the CLA.

@Ludv1gL Ludv1gL closed this Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants