New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync issues when repository deleted and re-created #2658
Comments
Turns out this is difficult to handle in synchronization in an efficient manner. For now, we will require manual deletion of the repository using The command line utility still requires a |
There is still a few edge cases that are not handled. Scenario 1
This will result in the newer repository being ignored, while the old repository remains active in the system. The permanent fix for this issue would be to check the number of rows updated after the insert. If 0, we know the insert was ignored due to a key violation. If this happens we should 1) check for the old repository and 2) remove the old repository and 3) re-try the insert. Scenario 2
This results in the following error (error message may vary by database vendor)
The permanent fix for this is to have a separate routine for repository updates vs repository renames. For repository renames we should check to see if a repository with the same name already exists. If yes, we can delete the old repository and insert the new repository. If no, we can update the existing repository. Short Term Workaround The short term solution is to delete the old repository from the system, and then re-synchronize, so that the new repository is inserted into the database. This endpoint must be invoked by an administrator.
|
@bradrydzewski I am on Scenario 1 currently
I tried |
Maybe I misunderstood how syncronization works, since when I run
|
in that case you may need to delete the repository from the database |
Can you elaborate? if it is "Not Found" I guess it is not in db already.. |
it is likely in the db. not found could indicate you no longer have access to the repository, which is expected because when you deleted it in github, your access entry was removed from the drone database. |
Ok, how can I remove it from drone db, any api for that? Or any hints? I am willing to dig deeper) |
|
I ran drone with docker, so I guess I need to enter container
and enter sqlite
But I have error |
@bradrydzewski figured out! Sync works. Thanks, I guess I just was tired yesterday. |
@bradrydzewski As a workaround I can add |
when trying to do this fix in sqlite i am getting the following.
I suspect this is because I have an encryption key for secrets, what is the process for decrypting so that it can be updated? |
@ChrisMcKenzie this would not be the case. Drone encrypts secrets in memory and saves the encrypted strings to the database. It does not encrypt the database itself. This error comes from sqlite and I believe to be unrelated to Drone itself. |
interesting ok, I will see what is going on there. |
oh duh, I was using |
So I guess my next question is, is there a way to tell which repo might have had this happen to it? |
@ChrisMcKenzie you should see an error in the Drone server logs that specifies which unique constraint was violated and using which value. Assuming you are using latest version of Drone. |
The message I am getting it
so I know that it is the repo_slug that is wrong I just don't know which repo it is trying sync. we are running version |
we have made a bunch of improvements to the conversion code over the past weeks and even in the past 24 hours. So you may want to try the 1.2 release or at least v1.1.1 of the CLI. If you have examples that are failing we may also be able to use them to improve the converter. But I'm afraid that troubleshooting may be limited without the option to upgrade :( |
@ChrisMcKenzie following up on previous comment, please consider creating an issue and providing a few samples of files that cannot automatically convert. There were a lot of improvements since 1.0.1 and I would hate for anyone to be stuck on an old version. We use the following issue tracker for our yaml converter https://github.com/drone/drone-yaml |
Do you have any suggestions on how to determine which repo is causing the duplicate key error? I'm not aware of any of our Github repos that were re-created, or renamed back to an existing name... We've recently run a migration from 0.8.x to 1.1. (The migrate tool worked like a breeze, except for the final
and the server logs a similar message:
I pulled the Drone repos DB and my organization's Github repositories and compared the IDs and I couldn't find anything amiss - each ID from github corresponded uniquely to an ID in the drone DB. |
I can push some improvements to capture the offending repository name and unique identifier in the error message. In this case I see |
That sounds very helpful. We are running server version 1.1 and drone-cli version 1.1.1, and I tried looking through the changelog for 1.2 to see if logging for the offending repository was already added, and it seemed like it was not. Thanks! |
Cool, the added logging made it immediately clear which repo had the issue. I deleted the row and the sync started working. I'm inquiring with the developers to see if that repo has been renamed, or... another one deleted & renamed, or if anything has happened with it at all. Thanks! edit: so yeah, the repo existed before, it was deleted, and then re-created with the exact same name. |
We added new batching logic that will appear in 1.5 behind a feature flag:
The new batch logic should resolve this issue but at the expense of slower syncs times. This will be most noticeable the first time you sync your repository list if it is large (e.g. an increase from 15 seconds to 30 seconds). It may also be noticeable for subsequent syncing attempts if the list of deltas is large. We will remove the feature flag in 1.6 pending successful testing at |
I believe I found another edge case:
Tried |
the new batch logic is now enabled by default in master via patch fa0ebed. this will be available in the tagged 1.6 release. in the event the new batch logic causes issues, you can rollback to the previous batch logic using the |
When a repository is deleted and then re-created with the same name, Drone is unable to add the repository to list because an entry with the same name exists but a different unique identifier.
We should be able to account for this in the synchornization process. If not, we should log some sort of error and then give a way to manually purge a repository by name from the database as a workaround.
The text was updated successfully, but these errors were encountered: