Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Hi @marcelomendoncasoares, this one is ready for a look when you have time. The failing CLI e2e check is |
FXschwartz
left a comment
There was a problem hiding this comment.
Hey @mackings, thanks for picking this up!. I went through the change and the fix looks right to me. It matches what the SQLite adapter already does, and I couldn't find any spots you missed.
The one thing I wanted to ask about is the test:
| await pod.shutdown(exitProcess: false); | ||
| }); | ||
|
|
||
| test( |
There was a problem hiding this comment.
I think both of these would pass on main as well, since nothing in them steps the clock and the old DateTime.now().difference(_startTime) also grows and doesn't go backwards in a normal run.
The session is also created with enableLogging: false (line 32), so the finalizeLog change isn't touched by them.
I don't see a good way to fake a clock step in a unit test here, so I'm wondering if we'd be better off dropping the file and just going with the manual check you described in the PR description. Or do you see a way to make it fail without the fix?
There was a problem hiding this comment.
You're right, I ran them without the fix and both pass. I looked at package:clock too, but its stopwatch reads the wall clock, so it would bring the bug back. I've dropped the file and updated the description.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf4a31becb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }) async { | ||
| _stopwatch.stop(); | ||
| final duration = session.duration; | ||
| final duration = _stopwatch.elapsed; |
There was a problem hiding this comment.
Keep the logged duration anchored to session creation
With database support and logging enabled, Session starts its monotonic timer and records startTime before server.createDatabase(this) invokes the synchronous databaseInterceptor, but the manager's stopwatch starts only after that callback returns. If an interceptor performs substantial setup, the close row reports a shorter duration than the session's elapsed time even though its SessionOpen.startTime includes that setup; measure this duration from the session's stopwatch or otherwise align both timer origins.
Useful? React with 👍 / 👎.
Session.duration, the query log, bulk data and the health check measured durations withDateTime.now(), so a system clock change while a session or query was running made the duration jump (negative after a step back). They now use aStopwatch.startTimeandlastDatabaseOperationTimestayDateTime.The session log now uses its own stopwatch for both the logged duration and the slow flag, so they always agree.
I tested it by running a session under libfaketime and stepping the clock: before,
session.durationwent to-0:00:58.98after a one-minute step back and1:00:01.5after a one-hour step forward; with the fix it shows the real elapsed time (~1 s).Fixes #6001
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes
None.