Added 3 attempts in upsert aggregation_status
This commit is contained in:
parent
e2bcfc016a
commit
74349c3253
|
@ -14,6 +14,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.aggregator.aggregation.AggregationInfo;
|
||||
import org.gcube.accounting.aggregator.aggregation.AggregationType;
|
||||
|
@ -205,7 +206,7 @@ public class PostgreSQLConnector extends PersistencePostgreSQL implements Aggreg
|
|||
|
||||
@Override
|
||||
public void upsertAggregationStatus(AggregationStatus aggregationStatus) throws Exception {
|
||||
for(int i=1; i<=3; i++){
|
||||
for(int i=0; i<3; i++){
|
||||
try {
|
||||
Connection connection = getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
|
@ -217,6 +218,15 @@ public class PostgreSQLConnector extends PersistencePostgreSQL implements Aggreg
|
|||
connection.commit();
|
||||
break;
|
||||
}catch (Throwable e) {
|
||||
if(i<3) {
|
||||
long delay = TimeUnit.MILLISECONDS.toMillis(100);
|
||||
logger.error("Unable to upsert aggregation status at attemp {}. Retrying in {} millis.", i, delay, e);
|
||||
Thread.sleep(delay);
|
||||
}else {
|
||||
logger.error("Unable to upsert aggregation status.", e);
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue