Dont fail on cleanup

This commit is contained in:
James Agnew 2017-06-30 08:42:11 -04:00
parent b44bdeec88
commit d626c58067
4 changed files with 13 additions and 10 deletions

View File

@ -35,8 +35,8 @@ public interface ISearchDao extends JpaRepository<Search, Long> {
@Query("SELECT s FROM Search s WHERE s.myUuid = :uuid")
public Search findByUuid(@Param("uuid") String theUuid);
@Query("SELECT s FROM Search s WHERE s.mySearchLastReturned < :cutoff")
public Collection<Search> findWhereLastReturnedBefore(@Param("cutoff") Date theCutoff);
@Query("SELECT s.myId FROM Search s WHERE s.mySearchLastReturned < :cutoff")
public Collection<Long> findWhereLastReturnedBefore(@Param("cutoff") Date theCutoff);
// @Query("SELECT s FROM Search s WHERE s.myCreated < :cutoff")
// public Collection<Search> findWhereCreatedBefore(@Param("cutoff") Date theCutoff);

View File

@ -71,13 +71,13 @@ public class StaleSearchDeletingSvcImpl implements IStaleSearchDeletingSvc {
@Autowired
private PlatformTransactionManager myTransactionManager;
protected void deleteSearch(final Search next) {
protected void deleteSearch(final Long theSearchPid) {
TransactionTemplate tt = new TransactionTemplate(myTransactionManager);
tt.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
Search searchToDelete = mySearchDao.findOne(next.getId());
ourLog.info("Expiring stale search {} / {}", searchToDelete.getId(), searchToDelete.getUuid());
Search searchToDelete = mySearchDao.findOne(theSearchPid);
ourLog.info("Deleting search {}/{} - Created[{}] -- Last returned[{}]", searchToDelete.getId(), searchToDelete.getUuid(), searchToDelete.getCreated(), searchToDelete.getSearchLastReturned());
mySearchIncludeDao.deleteForSearch(searchToDelete.getId());
mySearchResultDao.deleteForSearch(searchToDelete.getId());
mySearchDao.delete(searchToDelete);
@ -97,13 +97,10 @@ public class StaleSearchDeletingSvcImpl implements IStaleSearchDeletingSvc {
ourLog.debug("Searching for searches which are before {}", cutoff);
Collection<Search> toDelete = mySearchDao.findWhereLastReturnedBefore(cutoff);
Collection<Long> toDelete = mySearchDao.findWhereLastReturnedBefore(cutoff);
if (!toDelete.isEmpty()) {
for (final Search next : toDelete) {
ourLog.info("Deleting search {} - Created[{}] -- Last returned[{}]", next.getUuid(), next.getCreated(), next.getSearchLastReturned());
for (final Long next : toDelete) {
deleteSearch(next);
}

View File

@ -3320,6 +3320,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
List<String> ids = toUnqualifiedVersionlessIdValues(bundle);
assertThat(ids, contains(id1.getValue()));
assertThat(ids, not(contains(id2.getValue())));
} finally {
IOUtils.closeQuietly(resp);
}

View File

@ -75,6 +75,11 @@
paging to the database in that case. This fix also resolves a NullPointerException
when performing an $everything search. Thanks to Kamal Othman for reporting!
</action>
<action type="fix">
Correct an issue in JPA server on Postgres where searches with a long search URL
were not able to be automatically purged from the database after they were scheduled
for deletion. Thanks to Ravi Kuchi for reporting!
</action>
</release>
<release version="2.5" date="2017-06-08">
<action type="fix">