Skip to content

Commit

Permalink
use an order collection of registrations to avoid dead locks
Browse files Browse the repository at this point in the history
  • Loading branch information
0w3n-d committed Oct 15, 2024
1 parent d757eda commit 1c3ec56
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/database/src/postgres/postgres_db_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ impl PostgresDatabaseService {
) -> Result<(), DatabaseError> {
let mut client = self.pool.get().await?;

let mut sorted_entries = entries.to_vec();
sorted_entries.sort_by(|a, b| a.registration_info.registration.message.public_key.cmp(&b.registration_info.registration.message.public_key));

let batch_size = 10;
for chunk in entries.chunks(batch_size) {
for chunk in sorted_entries.chunks(batch_size) {
let transaction = client.transaction().await?;

let mut structured_params_for_reg: Vec<RegistrationParams> =
Expand Down

0 comments on commit 1c3ec56

Please sign in to comment.