Conversation
testing this some more in production I noticed that it was not effectively clearing the cache data for users who aren't signed in and active. That's because if they aren't connected there's no cache so the reboot doesn't get called. this fixes that. ### Change type - [x] `other` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Deletes the user's R2 snapshot before rebooting in `admin_migrateToGroups` to properly reset cache for offline users, and adds more detailed debug logs around migration and reboots. > > - **Sync Worker** > - **Migration flow** (`apps/dotcom/sync-worker/src/TLUserDurableObject.ts`): > - Delete user snapshot `USER_DO_SNAPSHOTS.delete(getUserDoSnapshotKey(...))` before cache reboot in `admin_migrateToGroups` to ensure fresh state. > - Add debug logs: start, result, and completion of migration. > - **Reboot logging** (`apps/dotcom/sync-worker/src/UserDataSyncer.ts`): > - Expand `reboot` debug message to include `hard` and `delay` flags. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 65e16b9. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
after trying this in staging yesterday we noticed a spike in sql connections. I had cursor hoist the connection to the parent process and clean up the migration script a little. ### Change type - [x] `other` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Switches batch user migration to a single-connection, sequential flow with per-user sleep, new stats/progress, and matching UI/API changes. > > - **Backend (sync-worker)**: > - Replace batch migration with sequential per-user loop using one PG pool; add `sleepMs` param only. > - Introduce `startUserMigration`, `getNextUnmigratedUser`, `getNumUnmigratedUsers`, `getTotalUsers` helpers. > - Use SQL function `migrate_user_to_groups(...)` and force user DO reboot; send richer stats (`totalUsers`, `usersToMigrate`, `successCount`, `failureCount`, `progress`). > - Update SSE endpoint `/app/admin/migrate_users_batch` to emit new progress schema; `/app/admin/unmigrated_users_count` now returns DB count directly. > - **Frontend (admin.tsx)**: > - Simplify Batch Migration UI: remove `batchSize` and `maxUsers`; add `sleepMs` only. > - Update confirmation text, help copy, and stats display to show `usersToMigrate` and percentage `progress`. > - Stream handling now directly sets `stats` from SSE `details`; updated controls to start/stop accordingly. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d86ab5f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )