chore(fxa-auth): Replace accountDevices call for refresh-token auth scheme #19698
+482
−37
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.
Because
accountDevices_XXstored procedureThis pull request
Issue that this pull request solves
Closes: FXA-12692
Checklist
Put an
xin the boxes that applyScreenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
For testing this, I wanted to be a thorough as possible using batches of seed data to compare using the prior
accountDevices_XXsproc to the newdeviceFromRefreshTokenId_1. The main advantage the the new query is that we're offloading the filter to mysql, reducing the number of scanned and joined rows:To this, I needed a way to insert a bunch of mock data in sessionTokens, refreshTokens, devices, etc. to cover a number of cases (noted below). I put all of the scripts necessary on a separate branch if you want to check it out!
Process:
UNHEX()causing added overheadperformance_schema.events_statements_summary_by_digestandperformance_schema.events_statements_summary_by_programwere truncated to start with a clean slate10times (though a larger data set might be valuable!)This shows a pretty clear picture that the new query improves execution time by about 2x. It's worth noting, most of these cases are extremes, with dozens or hundreds of devices, but even with low device/session accounts we're still seeing an improvement since there is no join to the
sessionTokentable necessary here.Results:
33333333333333333333333333333333- account with 100 devices, each with refresh token but no sessionTokens55555555555555555555555555555555- 50 devices with both sessionTokenId and refreshTokenIds, requiring join for all before sorting/filtering11111111111111111111111111111121- HUGE number of devices, 500 all with refresh tokens and sessionTokens99999999999999999999999999999999- devices with a LOT of device commands (not very pratical, but demonstrates overhead when joining and fan-out from joins) 20 devices for account each with 15 commands11111111111111111111111111111126- 500 devices all with sessionTokens and refreshTokensCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC- devices with dangling refresh token id’s that don’t exist in the oauth db. Should have no impact, but worth testing11111111111111111111111111111122- mixed commands, some devices have commands some don’t. our specific device requested doesAdditional Testing
I wanted to ensure that I didn't also break endpoints that accept this auth strategy. So, I leveraged the auth-client unit tests to call creating an OAuthToken and use that to request data from the various devices endpoints, here's an example.
Note
This test was not committed, but including here for purposes of showing testing!