Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • webapp webapp
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 713
    • Issues 713
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 26
    • Merge requests 26
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gittergitter
  • webappwebapp
  • Merge requests
  • !2284

Write to the correct GitLab `identity` field for refreshTokens and add migration script to run after (migration phase 1)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Eric Eastwood requested to merge 2838-gitlab-identity-migration-pt1 into develop May 18, 2022
  • Overview 2
  • Commits 3
  • Pipelines 3
  • Changes 4

Write to the correct GitLab identity field for refreshToken's and add migration script to run after (migration phase 1).

Part of #2838 (closed)

  1. First part of the migration (writing to the correct identity field, then migrating existing data)
  2. Second phase of the migration (actually using the refreshTokens), !2283 (merged)

Dev notes

node scripts/migration/fill-gitlab-identity-refresh-tokens.js
  • https://mongoosejs.com/docs/4.x/docs/api.html

Working with Mongo indexes

$ mongo gitter
> db.identities.find({ provider: 'gitlab' })
> db.identities.getIndexes()
> db.identities.dropIndex("name")

How to check if the script is using the new index we added

To see if it's using the index, see how the relevant entry uses IXSCAN

Mongo commands
$ mongo gitter
> db.getProfilingLevel()
0
> db.setProfilingLevel(2)
{ "was" : 0, "slowms" : 100, "ok" : 1 }

# Run the migration script

> db.system.profile.find().pretty()
// ...
{
        "op" : "query",
        "ns" : "gitter.identities",
        "query" : {
                "find" : "identities",
                "filter" : {
                        "refreshToken" : {
                                "$exists" : false
                        },
                        "provider" : "gitlab"
                },
                "batchSize" : 500
        },
        "keysExamined" : 2,
        "docsExamined" : 2,
        "fromMultiPlanner" : true,
        "cursorExhausted" : true,
        "keyUpdates" : 0,
        "writeConflicts" : 0,
        "numYield" : 0,
        "locks" : {
                "Global" : {
                        "acquireCount" : {
                                "r" : NumberLong(2)
                        }
                },
                "Database" : {
                        "acquireCount" : {
                                "r" : NumberLong(1)
                        }
                },
                "Collection" : {
                        "acquireCount" : {
                                "r" : NumberLong(1)
                        }
                }
        },
        "nreturned" : 2,
        "responseLength" : 1020,
        "protocol" : "op_query",
        "millis" : 0,
        "execStats" : {
                "stage" : "FETCH",
                "filter" : {
                        "$not" : {
                                "refreshToken" : {
                                        "$exists" : true
                                }
                        }
                },
                "nReturned" : 2,
                "executionTimeMillisEstimate" : 0,
                "works" : 4,
                "advanced" : 2,
                "needTime" : 0,
                "needYield" : 0,
                "saveState" : 0,
                "restoreState" : 0,
                "isEOF" : 1,
                "invalidates" : 0,
                "docsExamined" : 2,
                "alreadyHasObj" : 0,
                "inputStage" : {
                        "stage" : "IXSCAN",
                        "nReturned" : 2,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 3,
                        "advanced" : 2,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 0,
                        "restoreState" : 0,
                        "isEOF" : 1,
                        "invalidates" : 0,
                        "keyPattern" : {
                                "provider" : 1,
                                "refreshToken" : 1
                        },
                        "indexName" : "provider_1_refreshToken_1",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : true,
                        "indexVersion" : 1,
                        "direction" : "forward",
                        "indexBounds" : {
                                "provider" : [
                                        "[\"gitlab\", \"gitlab\"]"
                                ],
                                "refreshToken" : [
                                        "[null, null]"
                                ]
                        },
                        "keysExamined" : 2,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                }
        },
        "ts" : ISODate("2022-05-18T00:42:14.276Z"),
        "client" : "172.18.0.1",
        "allUsers" : [ ],
        "user" : ""
}
// ...
Edited May 19, 2022 by Eric Eastwood
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: 2838-gitlab-identity-migration-pt1