schlupov / copr / copr

Forked from copr/copr 4 years ago
Clone

76dbc56 frontend: fix slow rawhide_to_release command

1 file Authored by praiskup 4 years ago, Committed by praiskup 4 years ago,
    frontend: fix slow rawhide_to_release command
    
    This commit does three major things:
    a) it minimizes the amount of db queries,
    b) changes the code so we only fork the latest relevant rawhide builds
       in main_dir (not all the builds),
    c) commits the transaction for each copr project, both to have smaller
       transactions and to start the backend work ASAP.
    
    To minimize the db workload we now:
    - traverse only through projects that have a) "follow_fedora_branching"
      and b) which have the relevant rawhide CoprChroot enabled,
    - we preload the 'Copr -> CoprChroot -> MockChroot' in first query
    - we don't handle all builds in project, but only those which are
      relevant (have relevant _succeeded_ rawhide build_chroot, correspond
      to main copr_dir, and have the highest build_id)
    
    By this commit, the `rawhide_to_release fedora-rawhide-x86_64` command
    was optimized to about 1 minute run (for db dump from September
    2019), before it took more than 25 minutes (measured on local host, in
    production it used to be much worse).