This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new db74dd2 Improve the query to insert keys during a KEYS file upload
db74dd2 is described below
commit db74dd229c542284ae24a0599d56ac0fef339b9c
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Jul 18 18:34:05 2025 +0100
Improve the query to insert keys during a KEYS file upload
---
atr/blueprints/admin/admin.py | 2 +-
atr/storage/writers/keys.py | 29 ++++++++++++++++++++---------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/atr/blueprints/admin/admin.py b/atr/blueprints/admin/admin.py
index 73ae8a6..a8739b7 100644
--- a/atr/blueprints/admin/admin.py
+++ b/atr/blueprints/admin/admin.py
@@ -646,7 +646,7 @@ async def admin_test() -> quart.wrappers.response.Response:
import atr.storage as storage
async with aiohttp.ClientSession() as aiohttp_client_session:
- url = "https://downloads.apache.org/pulsar/KEYS"
+ url = "https://downloads.apache.org/beam/KEYS"
async with aiohttp_client_session.get(url) as response:
keys_file_text = await response.text()
# logging.info(f"Keys file text: {keys_file_text}")
diff --git a/atr/storage/writers/keys.py b/atr/storage/writers/keys.py
index 4ba7f77..956f5b8 100644
--- a/atr/storage/writers/keys.py
+++ b/atr/storage/writers/keys.py
@@ -121,22 +121,33 @@ class CommitteeMember:
await self.__data.begin_immediate()
committee = await self.committee()
- persisted_fingerprints: set[str] = set()
- for model in key_models:
- merged_key: sql.PublicSigningKey = await
self.__data.merge(model)
- persisted_fingerprints.add(merged_key.fingerprint)
+ key_values = [m.model_dump(exclude={"committees"}) for m in
key_models]
+ key_insert_result = await self.__data.execute(
+ sqlite.insert(sql.PublicSigningKey)
+ .values(key_values)
+ .on_conflict_do_nothing(index_elements=["fingerprint"])
+ )
+ key_insert_count = key_insert_result.rowcount
+ logging.info(f"Inserted {key_insert_count} keys")
+
+ persisted_fingerprints = {v["fingerprint"] for v in key_values}
await self.__data.flush()
existing_fingerprints = {k.fingerprint for k in
committee.public_signing_keys}
new_fingerprints = persisted_fingerprints - existing_fingerprints
-
if new_fingerprints:
- insert_values = [
+ link_values = [
{"committee_name": self.__committee_name,
"key_fingerprint": fp} for fp in new_fingerprints
]
- stmt = sqlite.insert(sql.KeyLink).values(insert_values)
- stmt =
stmt.on_conflict_do_nothing(index_elements=["committee_name",
"key_fingerprint"])
- await self.__data.execute(stmt)
+ link_insert_result = await self.__data.execute(
+ sqlite.insert(sql.KeyLink)
+ .values(link_values)
+ .on_conflict_do_nothing(index_elements=["committee_name",
"key_fingerprint"])
+ )
+ link_insert_count = link_insert_result.rowcount
+ else:
+ link_insert_count = 0
+ logging.info(f"Inserted {link_insert_count} key links")
await self.__data.commit()
except Exception as e:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]