Repo sync error

Started getting this today when sync’ing repos.
Running Drone 1.0.1 in K8S mode with a sqlite backend.

{"error":"UNIQUE constraint failed: repos.repo_slug","level":"warning","msg":"api: cannot synchrnoize account","request-id":"728056a0f38508e300ce76031d730a64","time":"2019-04-23T16:07:45Z","user.login":"<redacted>"}

I downloaded the sqlite db and deleted the 2 most recently-added repos. Sync works now. However, I’m pretty sure there is a bug somewhere because there was definitely no name clash. Since the repos.repo_slug column is basically <github_org>/<repo_name>, there can’t possibly be two repos with the same full name.

Drone uses the unique repository ID from github when performing synchronizations so that it can account for repository renames. As a result, when you delete a repository in github and then re-create a repository with the same name, it can cause issues because the underlying unique id will have changed. When this happens, you need to find the old repository and remove it.

Additionally, it would be helpful if you could provide us with some additional details to help us reproduce the problem, so that we can provide a more permanent solution. For example, do you know which repository is causing the issue? How did the duplicate name come about?

  • Did you delete and re-create a fork?
  • Did you delete and re-create a repository?
  • Did you rename the repository, and re-create a new repository with the same name?

Each one of these edge cases requires a slightly different solution if we want to automate the synchronization process. So it would be great to understand the state of the data, and get a sample so that we can reproduce.

I also recommend subscribing to the GitHub Issue which also provides a workaround for this problem that you can use to unblock until we have a permanent solution in place.