Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-6774

Cleaning up users fail if there is a backlog of more than 100 users

    XMLWordPrintable

Details

    Description

      Since 3.2, Stash by default delays the deletion of any user by a week to be resilient to transient deletions (see STASH-4631 for more details).

      This is internally performed by a background job, UserCleanupJob, that executes (again by default) every 6 hours. As part of this job, Stash fetches the users that were deleted in a User Directory a week or more ago. Then for each user, it marks them as deleted. (Stash cannot fully delete an user in the database because it needs to preserve the user's pull requests, comments, etc. However the user will no longer have access to Stash).

      The problem with the current implementation of UserCleanupJob is that it currently fetches the users (by batch of 100) and update them within the same transaction. As a result, if there is more 100 users, an error is thrown and as a result the transaction is rollback:

      2014-11-28 09:39:33,051 ERROR [clusterScheduler_Worker-1]  c.a.scheduler.core.JobLauncher Scheduled job with ID 'UserCleanupJob' failed
      java.util.NoSuchElementException: null
      	at com.google.common.collect.Iterators$9.next(Iterators.java:966) ~[guava-11.0.2-atlassian-01.jar:na]
      	at com.atlassian.stash.util.PagedIterable$PagedIterator.next(PagedIterable.java:48) ~[stash-util-3.2.7.jar:na]
      	at com.atlassian.stash.internal.user.DefaultUserAdminService$3.doInTransactionWithoutResult(DefaultUserAdminService.java:620) ~[stash-service-impl-3.2.7.jar:na]
      	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE]
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE]
      	at com.atlassian.stash.internal.user.DefaultUserAdminService.cleanupDeletedUsers(DefaultUserAdminService.java:608) ~[stash-service-impl-3.2.7.jar:na]
      	at com.atlassian.stash.internal.user.DefaultUserAdminService$UserCleanupJob.runJob(DefaultUserAdminService.java:648) ~[stash-service-impl-3.2.7.jar:na]
      	at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:127) [atlassian-scheduler-core-1.2.2.jar:na]
      	at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:101) [atlassian-scheduler-core-1.2.2.jar:na]
      	at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:80) [atlassian-scheduler-core-1.2.2.jar:na]
      	at com.atlassian.scheduler.quartz1.Quartz1Job.execute(Quartz1Job.java:32) [atlassian-scheduler-quartz1-1.2.2.jar:na]
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [quartz-1.8.6.jar:na]
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [quartz-1.8.6.jar:na]
      

      Attachments

        Issue Links

          Activity

            People

              pepoirot Pierre-Etienne Poirot (Inactive)
              pepoirot Pierre-Etienne Poirot (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: