Skip to content

feat: write account last-seen timestamp in a BigQuery table - #2663

Merged
chenba merged 8 commits into
masterfrom
sync-last-seen-stor-686
Oct 20, 2026
Merged

chenba merged 8 commits into
masterfrom
sync-last-seen-stor-686

Conversation

@chenba

@chenba chenba commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Because:

  • we want to know when an account was most recently "active" so we can help FxA delete inactive accounts

This commit:

  • buffers records of fxa uid, oauth client id, timestamp after successful token exchange
  • flushes record batches based on elapsed time or buffer size
  • writes records to the log if they were not successfully written to BQ
    • uses a separate logger so we won't overwhelm the queue of the main logger
  • adds a feature flag for the feature

Closes STOR-686

@chenba

chenba commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Sorry about the sizeable patch. A lot of it is to capture the data when we can't get it into BigQuery. That should be rare; we will have Sentry events if and when that happens.

@chenba
chenba requested review from pjenvey and taddes October 14, 2026 16:44
@chenba
chenba force-pushed the sync-last-seen-stor-686 branch from 5f44337 to f496921 Compare October 14, 2026 18:13
Because:
 - we want to know when an account was most recently "active" so we can
   help FxA delete inactive accounts

This commit:
 - buffers records of fxa uid, oauth client id, timestamp after
   successful token exchange
 - flushes record batches based on elapsed time or buffer size
 - writes records to the log if they were not successfully written to BQ 
   - uses a separate logger so we won't overwhelm the queue of the main
     logger
 - adds a feature flag for the feature
@chenba
chenba force-pushed the sync-last-seen-stor-686 branch from f496921 to 6abd8dd Compare October 14, 2026 18:56
Comment thread syncserver/src/logging.rs Outdated
Comment thread syncserver/src/logging.rs Outdated
.lock()
.unwrap_or_else(PoisonError::into_inner)
.clone()
.unwrap_or_else(slog_scope::logger)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth returning an explicit error in this case?

Comment thread syncserver/src/tokenserver/last_seen.rs Outdated
/// Actix's 30-second request drain plus one 10-second upload attempt.
pub const SHUTDOWN_BUDGET: Duration = Duration::from_secs(40);
/// How often the coordinator checks for rows recorded after a shutdown signal.
const SHUTDOWN_POLL: Duration = Duration::from_millis(100);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can avoid this poll by tracking the draining (see this branch)

@chenba
chenba force-pushed the sync-last-seen-stor-686 branch from f88e810 to d828074 Compare October 16, 2026 16:49
@chenba
chenba requested a review from pjenvey October 20, 2026 03:37
@chenba
chenba merged commit a62d063 into master Oct 20, 2026
32 checks passed
@chenba
chenba deleted the sync-last-seen-stor-686 branch October 20, 2026 21:32
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