Skip to content

refactor(auth): extract forced-password session cleanup and own server teardown (S08-C1b) - #372

Merged
voidvec merged 3 commits into
masterfrom
refactor/forced-password-change-session-state
Nov 27, 2026
Merged

voidvec merged 3 commits into
masterfrom
refactor/forced-password-change-session-state

Conversation

@voidvec

@voidvec voidvec commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

S08-C1b extracts forced-password-change session cleanup at the existing successful refresh-token revocation boundary. The new PostgreSQL HTTP regression also exposed abnormal server shutdown; this PR adds explicit ownership and teardown of startup workers and identity/plugin dependencies.

Changes

  • A private helper performs the same eight ordered session erasures and exactly one session-ID rotation. The guard, database operations, failure responses, audit, verification email and success response ordering stay intact.
  • Add real Drogon Session characterization and PostgreSQL HTTP acceptance, including fixture-user retirement and abnormal child-server exit detection.
  • Replace detached startup/migration workers with owned, joinable workers and interruptible retry delays. POSIX shutdown uses a blocked SIGTERM/SIGINT set and a sigwait watcher; Windows retains its existing signal-handling path.
  • Explicitly clear controller references and release identity services, provider-refresh ownership and plugin/cache dependencies during teardown. The shutdown fix adds no skip, suppression or accepted-exit-code relaxation.

Rebase audit

Current head: 1debed0b06fd813415e41729b400f886bcd5709a, based on master df6f2cef5c1e2d40878b25f5305db385297741aa after #379 was merged first.

The three commits rebased without conflicts and retain all three stable patch IDs. Net scope remains 15 files; 14 are byte-identical to the approved pre-rebase head. Inverse substitution of the helper reconstructs the entire latest-master SessionController byte-for-byte, preserving all newer upstream changes and the extraction boundary.

Validation on the current head

  • CI run 45992476459: static checks, full frontend checks, frontend-image smoke, Linux, Windows and macOS passed. SDK Smoke job 140497429069 also passed; the complete CI run is successful.
  • Linux job 140486645075 passed all 719 CTest entries, including real-Session tests and forced-password PostgreSQL HTTP acceptance, plus its subsequent backend checks.
  • PR ASan+UBSan run 45992476401, job 140483515730: all 719 CTest entries passed, including PostgreSQL HTTP acceptance.
  • Manual sanitizer run 45992517950: TSan job 140483664561 passed all 719 CTest entries and ten consecutive real-Session repetitions; ASan+UBSan job 140483665072 also passed all 719 entries. Neither job has skipped/not-run CTest entries.
  • Optional Feature Matrix run 45992476426: all three Social/WebAuthn combinations passed build, tests and installed-SDK consumption.
  • Advisory Coverage run 45992476468 completed its tests and passed the coverage ratchet: no library dropped more than 0.5 percentage points below baseline. Security run 45992476574 passed.
  • macOS passed its 718-entry CTest invocation. The PostgreSQL-only HTTP acceptance returns skip code 77 under its memory-storage config; macOS does not substitute for the Linux PostgreSQL validation above.

The existing approval is retained after the audited rebase. All current-head validation listed above is complete and successful; there are no unresolved review threads.

@voidvec
voidvec force-pushed the refactor/forced-password-change-session-state branch from 55d2423 to febc78d Compare November 25, 2026 00:43
wangrh0909
wangrh0909 previously approved these changes Nov 25, 2026
@voidvec
voidvec force-pushed the ci/tsan-instrumented-framework-dependencies branch from 88f1525 to 32876c6 Compare November 25, 2026 09:59
@voidvec
voidvec force-pushed the refactor/forced-password-change-session-state branch 2 times, most recently from bdedefa to 4701a5f Compare November 25, 2026 10:30
@voidvec
voidvec force-pushed the ci/tsan-instrumented-framework-dependencies branch from fbcb57e to 882583d Compare November 27, 2026 04:47
@voidvec

voidvec commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

PR 评审:阻碍合入项清单

基于当前 head 4701a5f7 的代码与 CI 核查(ForcedPasswordChangeSessionState.{h,cc} 对 8 次 session.erase(...) 与 1 次 changeSessionIdToClient() 的提取与原 SessionController.cc 逻辑等价,重构本身无问题),以下事项阻碍合入:

1. [CI 门禁失败 — 核心阻塞] 新增 ForcedPasswordChangeSessionState_OutOfProcess 在 Linux 全线构建腿均因服务端关闭异常而失败

  • 证据(head 4701a5f7):
    • CI Run 45595703359:Build & Test (linux) 失败(ForcedPasswordChangeSessionState_OutOfProcess 报 cleanup FAILED: unexpected server exit code: -11 [SIGSEGV],并导致 SDK Smoke 被跳过)。
    • Sanitizers Run 45595709867:ASan + UBSan (linux, full suite) 失败(unexpected server exit code: 1);TSan nightly (linux, full suite) 失败(unexpected server exit code: 66)。
    • Optional Feature Matrix Run 45595715186:Social ON / WebAuthn OFF、Social OFF / WebAuthn ON、Social OFF / WebAuthn OFF 三个组合全部失败。
  • 修复建议:查明并修复服务端受控退出时在 Linux / ASan / TSan 下的崩溃与异常退出根因(不可通过放宽退出码断言或跳过测试绕过)。

2. [堆叠分支 / 缺少 PR 自动门禁] Base 分支指向未合入的 #370

  • 当前 base 为 ci/tsan-instrumented-framework-dependencies,未触发 pull_request (branches: [master]) 自动工作流(statusCheckRollup 为空)。
  • 修复建议:待 PR ci: complete sanitizer instrumentation and fix test data races #370 合入 master 后,rebase 到最新 master,将 base 改回 master 并触发完整 PR 门禁全绿。

3. [PR 状态与评审时效] 仍处于 Draft 状态,且现有 Approve 基于旧提交

  • 当前仍为 Draft,且 wangrh0909 的 APPROVED 停留在旧提交 febc78d8(早于当前 4701a5f7)。问题修复并 rebase 后需转为 Ready for review 并重新获取有效批准。

@voidvec
voidvec force-pushed the ci/tsan-instrumented-framework-dependencies branch from 882583d to 846a7ee Compare November 27, 2026 06:02
@voidvec
voidvec changed the base branch from ci/tsan-instrumented-framework-dependencies to master November 27, 2026 07:05
@voidvec
voidvec dismissed wangrh0909’s stale review November 27, 2026 07:05

The base branch was changed.

wangrh0909
wangrh0909 previously approved these changes Nov 27, 2026
@voidvec voidvec changed the title refactor(auth): extract forced password change session cleanup (S08-C1b) refactor(auth): extract forced-password session cleanup and own server teardown Nov 27, 2026
@voidvec
voidvec force-pushed the refactor/forced-password-change-session-state branch from 6d11a61 to 1debed0 Compare November 27, 2026 11:40
@voidvec voidvec changed the title refactor(auth): extract forced-password session cleanup and own server teardown refactor(auth): extract forced-password session cleanup and own server teardown (S08-C1b) Nov 27, 2026
@voidvec
voidvec marked this pull request as ready for review November 27, 2026 12:39
@voidvec
voidvec merged commit ebb6a57 into master Nov 27, 2026
18 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T12:41:04.756339Z 1debed0 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@voidvec
voidvec deleted the refactor/forced-password-change-session-state branch November 27, 2026 12:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1debed0b06

ℹ️ 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".

Comment thread apps/server/src/main.cc
Comment on lines +537 to +540
std::thread signalWatcher(
[&shutdownSigset, &normalExitRequested, &signalHandled, &startupRunner]() {
int sig = 0;
if (sigwait(&shutdownSigset, &sig) == 0 &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Create the signal watcher after Drogon's process fork

On Linux, the baseline, production, and benchmark configurations enable app.relaunch_on_error, so Drogon forks inside run() (the same behavior is explicitly worked around in tests/test_main.cc:254-259). This watcher is created before that fork: the serving child inherits the blocked SIGTERM/SIGINT mask but not the watcher thread. Consequently, the child cannot consume either shutdown signal and requires SIGKILL instead of performing graceful teardown. Start the watcher in the serving process after Drogon's fork, while arranging signal masking before worker creation.

Useful? React with 👍 / 👎.

Comment thread apps/server/src/main.cc
Comment on lines +141 to +142
});
if (result->get_future().get())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the startup-result wait interruptible during shutdown

If shutdown arrives while a startup database operation is pending, requestStop() only interrupts the retry delay; it cannot release this unconditional future wait. The newly added startupRunner.joinAll() therefore prevents process exit until the database callback completes. This can exceed the shutdown grace period with the production database timeout of 60 seconds, or hang indefinitely with the baseline configuration's disabled timeout (timeout: -1.0) when the database is unavailable. Use a bounded, stop-aware wait so joining the startup workers does not depend on database recovery.

Useful? React with 👍 / 👎.

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