Skip to content

Commit

Permalink
Merge pull request #105 from yma96/main
Browse files Browse the repository at this point in the history
Add cover case for Cassandra reconnect when doing mapper save
  • Loading branch information
yma96 authored Nov 4, 2024
2 parents 8c7bbd0 + a519be5 commit 0aecf11
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,33 @@ public void addTrackingRecord( String trackingId, PathsPromoteResult result ) th
dtxPromoteRecord.setTrackingId(trackingId);
dtxPromoteRecord.setPromotionId(result.getRequest().getPromotionId());
dtxPromoteRecord.setResult(objectMapper.writeValueAsString( result ));
promoteRecordMapper.save(dtxPromoteRecord);

boolean exception = false;
try
{
if ( session == null || session.isClosed() )
{
client.close();
client.init();
this.init();
}
promoteRecordMapper.save(dtxPromoteRecord);
}
catch ( NoHostAvailableException e )
{
exception = true;
logger.error( "Cannot connect to host, reconnect once more with new session.", e );
}
finally
{
if ( exception )
{
client.close();
client.init();
this.init();
promoteRecordMapper.save(dtxPromoteRecord);
}
}

// Also update query-by-path table
updateQueryByPath(trackingId, result.getRequest(), result.getCompletedPaths(), false);
Expand Down

0 comments on commit 0aecf11

Please sign in to comment.