Skip to content

Commit

Permalink
[PAGOPA-2282] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang committed Oct 30, 2024
1 parent 2178f5d commit 180faf5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 37 deletions.
4 changes: 2 additions & 2 deletions performance-test/python-test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import methods


NUMBER_OF_PAYMENTS = 5000
NUMBER_OF_PAYMENTS = 30000
MAX_PAYMENTS_PER_ADD_OPERATION = 1000

def main(URL, subkey):
logging.basicConfig(level=logging.INFO)

flow_date = "2024-10-15"
flow_date = "2024-10-30"
tmstmp = timestamp = int(time.time())
flow_name = f"{flow_date}88888888888-{tmstmp}"

Expand Down
6 changes: 3 additions & 3 deletions performance-test/python-test/methods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import random
import json, logging, requests, time
import utility


def create_empty_flow(url, flow_name, flow_date, total_payments, key):
Expand Down Expand Up @@ -85,13 +85,13 @@ def generate_payments(number_of_payments, total_amount, date):
payments = []
iuvs = set()
for idx in range(number_of_payments):
iuv = utility.get_random_numeric_string(15)
iuv = get_random_numeric_string(15)
if iuv not in iuvs:
iuvs.add(iuv)
payments.append({
"index": idx + 1,
"iuv": iuv,
"iur": utility.get_random_numeric_string(11),
"iur": get_random_numeric_string(11),
"pay": total_amount / number_of_payments,
"idTransfer": 1,
"payStatus": "EXECUTED",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static PanacheQuery<PanacheMongoEntityBase> findByFdrAndPspId(String fdr,
Parameters.with("fdr", fdr).and("pspId", pspId).map());
}

public static void deleteByFdrAndIds(String fdr, List<ObjectId> objectIds) {
delete(
"ref_fdr = :fdr and _id in :objectIds",
Parameters.with("fdr", fdr).and("ids", objectIds).map());
}

public static long deleteByFdrAndIndexes(String fdr, List<Long> indexList) {
return delete(
"ref_fdr = :fdr and index in :indexes",
Expand Down

This file was deleted.

15 changes: 7 additions & 8 deletions src/main/java/it/gov/pagopa/fdr/service/psps/PspsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.bson.types.ObjectId;
import org.jboss.logging.Logger;
import org.jboss.logging.MDC;

Expand Down Expand Up @@ -362,8 +363,8 @@ private void batchDelete(String fdr, List<FdrPaymentInsertEntity> paymentInsertE
.toList();
// sequential stream
batches.forEach(batch -> {
List<Long> indexes = paymentInsertEntities.stream().map(FdrPaymentInsertEntity::getIndex).toList();
FdrPaymentInsertEntity.deleteByFdrAndIndexes(fdr, indexes);
List<ObjectId> objectIds = paymentInsertEntities.stream().map(entity -> entity.id).toList();
FdrPaymentInsertEntity.deleteByFdrAndIds(fdr, objectIds);
});
}

Expand All @@ -374,15 +375,15 @@ private void parallelPersist(String fdr, List<FdrPaymentPublishEntity> fdrPaymen
.mapToObj(i -> fdrPaymentPublishEntities.subList(i * batchSize, Math.min((i + 1) * batchSize, fdrPaymentPublishEntities.size())))
.toList();
batchesPublish.parallelStream().forEach(FdrPaymentPublishEntity::persistFdrPaymentPublishEntities);
log.infof("Published fdrPaymentPublishEntities of fdr[%s]", fdr);
log.debugf("Published fdrPaymentPublishEntities of fdr[%s]", fdr);

Check failure

Code scanning / CodeQL

Log Injection High

This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
}

private void addToConversionQueue(boolean internalPublish, FdrInsertEntity fdrEntity) {
// add to conversion queue
if (internalPublish) {
log.info("NOT Add FdrInsertEntity in queue fdr message");
log.debugf("NOT Add FdrInsertEntity in queue fdr message");
} else {
log.info("Starting add FdrInsertEntity in queue fdr message");
log.debugf("Starting add FdrInsertEntity in queue fdr message");
conversionQueue.addQueueFlowMessage(
FdrMessage.builder()
.fdr(fdrEntity.getFdr())
Expand All @@ -391,12 +392,11 @@ private void addToConversionQueue(boolean internalPublish, FdrInsertEntity fdrEn
.retry(0L)
.revision(fdrEntity.getRevision())
.build());
log.info("End add FdrInsertEntity in queue fdr message");
log.debugf("End add FdrInsertEntity in queue fdr message");
}
}

private void rePublish(String fdr, String pspId, FdrPublishEntity fdrPublishEntity) {
log.info("Starting write to re");
String sessionId = (String) MDC.get(TRX_ID);
MDC.put(EVENT_CATEGORY, EventTypeEnum.INTERNAL.name());
reService.sendEvent(
Expand All @@ -413,7 +413,6 @@ private void rePublish(String fdr, String pspId, FdrPublishEntity fdrPublishEnti
.revision(fdrPublishEntity.getRevision())
.fdrAction(FdrActionEnum.PUBLISH)
.build());
log.info("End write to re");
}

@WithSpan(kind = SERVER)
Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ quarkus.mongodb.connection-string=${MONGODB_CONNECTION_STRING:${mockserver.mongo
%dev.quarkus.mongodb.connection-string=mongodb://root:example@localhost:27017/
quarkus.mongodb.database=fdr

###################
## Vert.x
###################
# quarkus.vertx.max-event-loop-execute-time=2s

###################
## ADAPTER API CONFIG CACHE
###################
Expand Down

0 comments on commit 180faf5

Please sign in to comment.