Skip to content

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Apr 28, 2025

This fixes an error when flushing session activity when MAS is deployed across multiple processes: Failed to flush activity tracker: error returned from database: deadlock detected

This happens because PG will lock rows in the order they appear in the transaction, so if we don't order them predictably, two transactions can deadlock

I've also did a few pass-by fixes, like using tokio::time::interval instead of tokio::time::sleep for the flush loop.

I've also added a gauge to track the number of pending records in the activity tracker, so that we can detect better when it's misbehaving

Copy link

cloudflare-workers-and-pages bot commented Apr 28, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: e2dde82
Status: ✅  Deploy successful!
Preview URL: https://fd807a23.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-activity-tracker-de.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose enabled auto-merge April 28, 2025 08:48
@sandhose sandhose added the T-Defect Something isn't working label Apr 28, 2025
@sandhose sandhose merged commit e243b62 into main Apr 28, 2025
30 checks passed
@sandhose sandhose deleted the quenting/activity-tracker-deadlock branch April 28, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Defect Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant