Skip to content

Reload process to use DB-assigned updated_at timestamps#4935

Open
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:fix-process-observer-updated-at-drift
Open

Reload process to use DB-assigned updated_at timestamps#4935
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:fix-process-observer-updated-at-drift

Conversation

@philippthun
Copy link
Member

@philippthun philippthun commented Mar 18, 2026

When a process is saved, Sequel's timestamps plugin sets updated_at in-memory before the DB transaction commits. If the runner is called after the transaction commits (via after_commit callback), it receives a stale in-memory timestamp that may differ from the DB-assigned value.

ProcessesSync compares process.updated_at against the LRP annotation to detect drift. A stale timestamp causes unnecessary re-sync requests.

This commit adds process.reload before passing the process to runners in ProcessObserver, ProcessRouteHandler, and AppUpdate. This ensures the runner receives the DB-assigned timestamp.

Also removes an incorrect comment in ProcessRestart about timestamp precision differences - testing confirmed the timestamps match when the runner is called inside the transaction.

Adds skip_process_observer_on_update in AppUpdate to prevent redundant ProcessObserver.updated calls when metric tags are being updated.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@philippthun philippthun force-pushed the fix-process-observer-updated-at-drift branch from 55ab2a2 to 6b7fb87 Compare March 19, 2026 13:59
@philippthun philippthun changed the title Fix ProcessObserver to use DB-assigned updated_at timestamps Reload process to use DB-assigned updated_at timestamps Mar 19, 2026
When a process is saved, Sequel's timestamps plugin sets updated_at
in-memory before the DB transaction commits. If the runner is called
after the transaction commits (via after_commit callback), it receives
a stale in-memory timestamp that may differ from the DB-assigned value.

ProcessesSync compares process.updated_at against the LRP annotation
to detect drift. A stale timestamp causes unnecessary re-sync requests.

This commit adds process.reload before passing the process to runners
in ProcessObserver, ProcessRouteHandler, and AppUpdate. This ensures
the runner receives the DB-assigned timestamp.

Also removes an incorrect comment in ProcessRestart about timestamp
precision differences - testing confirmed the timestamps match when
the runner is called inside the transaction.

Adds skip_process_observer_on_update in AppUpdate to prevent redundant
ProcessObserver.updated calls when metric tags are being updated.
@philippthun philippthun force-pushed the fix-process-observer-updated-at-drift branch from 6b7fb87 to f1bd777 Compare March 19, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant