Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fully delete abandoned commit from Gerrit DB AND 'query'

Tags:

sql

lucene

gerrit

I am trying to fully purge a change from Gerrit and running into some problems.

Previously I tried to follow this guide to achieve my goal:

https://www.onyxpoint.com/deleting-abandoned-commits-from-gerrit-code-review/

I messed this up however, and somehow managed to do the following:

  • Purge the offending change-id from all the tables in the Gerrit gsql database
  • The change still appears in the web-interface, but if I click on it, it fires an error: "The page you requested was not found, or you do not have permission to view this page."
  • If I run 'gerrit query' for the change, it still shows up, replete with all information.

Where is the change information coming from if it is not in the DB??? I also tried flushing all caches. Is it somewhere in the search index for lucene or something?

This is not super important, but it is really driving me nuts!

like image 705
allowanonplz123 Avatar asked Dec 25 '22 20:12

allowanonplz123


2 Answers

In my case, I didn't have to perform a re-index. But an additional step(5):

  1. Open the GSQL interface

    $ gerrit-cli gsql
    
  2. The following command will mark the change set as a draft change set in the Gerrit database.

    gerrit> update changes set status='d' where change_id='64581';
    
  3. Next, update the associated patch sets.

    gerrit> update patch_sets set draft='Y' where change_id='64581';
    gerrit> \q
    
  4. Prior to making further changes, you need to make sure that the Gerrit caches have been flushed. If you don’t do this, you may end up with strange results when using the Web UI in relation to this change set.

    $ gerrit-cli flush-caches --cache changes
    
  5. Ensure that the administrator has "View Drafts" and "Delete Drafts" permission on the repo for refs/* enter image description here
  6. Finally, delete the patch set(s) that you had previously abandoned. In this case, we’re going to assume that you have two patch sets to delete.

    $ gerrit-cli review 64581,1 --delete
    $ gerrit-cli review 64581,2 --delete
    

    Deleting each patch-set one by one can be a PITA. Nuke 'em in one go using the GUI: enter image description here

like image 101
Nehal J Wani Avatar answered Dec 27 '22 18:12

Nehal J Wani


Queries use Gerrit's secondary index (by default Lucene-based) so if you modify the database outside of Gerrit you have to reindex the data with the reindex command:

$ java -jar path/to/gerrit.war reindex -d path/to/gerrit-site-dir

This command should only be executed when Gerrit isn't running.

like image 44
Magnus Bäck Avatar answered Dec 27 '22 19:12

Magnus Bäck