PR#4073: sort checksums before inserting

Merges #4073
https://pagure.io/koji/pull-request/4073

Fixes: #4072
https://pagure.io/koji/issue/4072
deadlocks in create_rpm_checksum
This commit is contained in:
Tomas Kopecek 2024-04-24 15:00:03 +02:00
commit d0de585229
2 changed files with 16 additions and 6 deletions

View file

@ -14,7 +14,7 @@ from urllib.parse import quote
sys.path.insert(0, os.getcwd())
import koji
from kojihub import auth, kojixmlrpc, kojihub
from kojihub import auth, kojixmlrpc, kojihub, db
from koji.context import context
import koji.xmlrpcplus
@ -104,6 +104,8 @@ def get_options():
parser.add_option('--user', '-u', help='execute as user')
parser.add_option('--exclusive', '-x', action='store_true',
help='emulate an exclusive session')
parser.add_option('-n', '--no-commit', action='store_true',
help='skip commit')
opts, args = parser.parse_args()
# parse request from args
@ -149,10 +151,16 @@ def set_config(environ):
environ['koji.hub.ConfigDir'] = lconfigd
def skip_commit(cnx):
print('Skipping commit')
def main():
options = get_options()
if options.pdb:
kojixmlrpc.ModXMLRPCRequestHandler.handle_rpc = handle_rpc
if options.no_commit:
db.DBWrapper.commit = skip_commit
environ = {}
environ['SCRIPT_FILENAME'] = kojixmlrpc.__file__

View file

@ -16116,11 +16116,13 @@ def create_rpm_checksum(rpm_id, sigkey, chsum_dict):
f"rpm ID {r['rpm_id']}, sigkey {r['sigkey']} and "
f"checksum type {koji.CHECKSUM_TYPES[r['checksum_type']]}.")
if chsum_dict:
insert = BulkInsertProcessor(table='rpm_checksum')
for func, chsum in chsum_dict.items():
insert.add_record(rpm_id=rpm_id, sigkey=sigkey, checksum=chsum,
checksum_type=koji.CHECKSUM_TYPES[func])
insert.execute()
for func, chsum in sorted(chsum_dict.items()):
data = {'rpm_id': rpm_id,
'sigkey': sigkey,
'checksum': chsum,
'checksum_type': koji.CHECKSUM_TYPES[func]}
upsert = UpsertProcessor(table='rpm_checksum', data=data, skip_dup=True)
upsert.execute()
def reject_draft(data, is_rpm=False, error=None):