fix(#10452): isolate telemetry DB per user and fix race condition
User telemetry DB reused when logging in as a different user
Summary
This PR fixes two critical issues with the telemetry service:
-
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.
-
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
Closes #10452
@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
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.