Repository: atlas Updated Branches: refs/heads/master 59f83fc06 -> 8663eb1de
ATLAS-2195: fix to close trasaction left open while queries index keys (#2) Signed-off-by: Madhan Neethiraj <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/8663eb1d Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/8663eb1d Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/8663eb1d Branch: refs/heads/master Commit: 8663eb1dedfc9f3136ea44460055f7e332e3212c Parents: 59f83fc Author: Ashutosh Mestry <[email protected]> Authored: Fri Oct 13 17:55:08 2017 -0700 Committer: Madhan Neethiraj <[email protected]> Committed: Fri Oct 13 19:35:52 2017 -0700 ---------------------------------------------------------------------- .../graph/GraphBackedSearchIndexer.java | 32 +++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/8663eb1d/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java index 8aa2237..9cd2991 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java @@ -261,23 +261,33 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang try { management = provider.get().getManagementSystem(); - } catch (RepositoryException excp) { - LOG.error("failed to get indexedKeys from graph", excp); - } - if (management != null) { - AtlasGraphIndex vertexIndex = management.getGraphIndex(Constants.VERTEX_INDEX); + if (management != null) { + AtlasGraphIndex vertexIndex = management.getGraphIndex(Constants.VERTEX_INDEX); + + if (vertexIndex != null) { + recomputeIndexedKeys = false; - if (vertexIndex != null) { - recomputeIndexedKeys = false; + Set<String> indexKeys = new HashSet<>(); - Set<String> indexKeys = new HashSet<>(); + for (AtlasPropertyKey fieldKey : vertexIndex.getFieldKeys()) { + indexKeys.add(fieldKey.getName()); + } - for (AtlasPropertyKey fieldKey : vertexIndex.getFieldKeys()) { - indexKeys.add(fieldKey.getName()); + vertexIndexKeys = indexKeys; } - vertexIndexKeys = indexKeys; + management.commit(); + } + } catch (Exception excp) { + LOG.error("getVertexIndexKeys(): failed to get indexedKeys from graph", excp); + + if (management != null) { + try { + management.rollback(); + } catch (Exception e) { + LOG.error("getVertexIndexKeys(): rollback failed", e); + } } } }
