cht-core icon indicating copy to clipboard operation
cht-core copied to clipboard

fix(#10452): isolate telemetry DB per user and fix race condition

Open CommitToday opened this issue 1 month ago • 2 comments

User telemetry DB reused when logging in as a different user

Summary

This PR fixes two critical issues with the telemetry service:

  1. Fixed telemetry DB isolation issue where databases were incorrectly shared between different users on the same day. The fix ensures that both date AND username are verified when selecting the appropriate telemetry database for a user.

  2. Fixed a race condition in the submitIfNeeded method where the isAggregationRunning flag was improperly managed. The flag is now correctly set once before the DB processing loop and reset in a finally block to prevent race conditions.

Changes Made

  • Updated length check in getCurrentTelemetryDB and submitIfNeeded methods from >= 4 to >= 5 to properly handle DB name format
  • Restructured submitIfNeeded method to properly manage isAggregationRunning flag with try/finally
  • Added test case to verify that different users have separate telemetry databases on the same day

Testing

  • All existing tests pass
  • New test added to prevent regression of the user isolation issue

Verification

  • Linting passes successfully
  • Changes follow project conventions
  • Race condition properly addressed

Closes #10452

CommitToday avatar Nov 12 '25 12:11 CommitToday

Closes #10452

CommitToday avatar Nov 12 '25 22:11 CommitToday

@SoulSniper1212 Thanks for the PR!

I left a couple requests. Once those are addressed this should be good to go!

Thanks for the feedback, I addressed them

CommitToday avatar Nov 21 '25 17:11 CommitToday

This PR is now marked "stale" after 30 days without activity. It will be closed automatically in 10 days unless you add a comment, push new changes or remove the "stale" label.

github-actions[bot] avatar Dec 22 '25 00:12 github-actions[bot]