Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete a datasource if the source on the connection string does not exists #2152 #2156

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.ohdsi.webapi.util.SessionUtils;
import org.ohdsi.webapi.util.SourceUtils;
import org.ohdsi.webapi.util.StatementCancel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Objects;
Expand All @@ -22,6 +24,7 @@

@Component
public class CohortGenerationCacheProvider extends AbstractDaoService implements GenerationCacheProvider {
private static final Logger log = LoggerFactory.getLogger(CohortGenerationCacheProvider.class);

private static final String CACHE_VALIDATION_TIME = "Checksum of Generation cache for designHash = {} has been calculated in {} milliseconds";

Expand Down Expand Up @@ -88,9 +91,16 @@ public void remove(Source source, Integer designHash) {
new String[]{SourceUtils.getResultsQualifier(source), designHash.toString()}
);
sql = SqlTranslate.translateSql(sql, source.getSourceDialect());
// StatementCancel parameter is needed for calling batchUpdate of CancelableJdbcTemplate class
// Without StatementCancel parameter JdbcTemplate.batchUpdate will be used.
// JdbcTemplate incorrectly determines the support of batch update for impala datasource
getSourceJdbcTemplate(source).batchUpdate(new StatementCancel(), SqlSplit.splitSql(sql));

try {
// StatementCancel parameter is needed for calling batchUpdate of CancelableJdbcTemplate class
// Without StatementCancel parameter JdbcTemplate.batchUpdate will be used.
// JdbcTemplate incorrectly determines the support of batch update for impala datasource
getSourceJdbcTemplate(source).batchUpdate(new StatementCancel(), SqlSplit.splitSql(sql));
} catch (final Exception e) {
// if source is unavailable it throws exception that prevents source from being deleted.
// ignore exception and proceed with deletion.
log.warn("Cannot remove generation caches from source {}", source.getSourceId());
}
}
}