[ https://issues.apache.org/jira/browse/GEODE-3589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
nabarun updated GEODE-3589: --------------------------- Component/s: regions > If exception occurs during during index maintenance as a part of a put > operation, Geode must revert/rollback all changes the put operation had > initiated. > ---------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: GEODE-3589 > URL: https://issues.apache.org/jira/browse/GEODE-3589 > Project: Geode > Issue Type: Bug > Components: regions > Affects Versions: 1.3.0 > Reporter: nabarun > > Case: > 1. A put operation is initiated. > 2. While updating the index as a part of the put operation, an exception > occurs. > 3. Every action that the put had initiated must be rolled back and an > exception must be thrown back to user. > *+Simple acceptance must be that this test must pass:+* > Add this method to the Portfolio class in Geode code base > {code: title=Portfolio.java} > public int throwExceptionMethod() { > if (ID % 2 == 0) { > throw new IllegalStateException(); > } else { > return ID; > } > } > {code} > And the test > {code: title=RollbackOnIndexMaintenanceException.java} > @Test > public void > allActionsInitiatedByPutMustBeRolledBackIfAnIMQExceptionOccurs() throws > Exception { > String regionName = "REGION_NAME"; > Cache cache = getCache(); > Region region = > > getCache().createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create(regionName); > QueryService queryService = cache.getQueryService(); > Index exceptionIndex = > queryService.createIndex("exceptionIndex", "throwExceptionMethod", > "/" + regionName); > Index idIndex = queryService.createIndex("idIndex", "ID", "/" + > regionName); > region.put(0, new Portfolio(1)); > try { > region.put(1, new Portfolio(2)); > fail("An Index maintenance exception must have been thrown"); > } catch (Exception exception) { > if (!(exception.getCause() instanceof IMQException)) { > fail("An Index maintenance exception was expected."); > } > } > assertEquals( > "The exception while doing the last put must revert the entry from > the index which does not cause an exception while doing the update ", > 1, idIndex.getStatistics().getNumberOfValues()); > assertEquals( > "The exception while doing the last put should not let that entry be > added to the index which caused the exception", > 1, exceptionIndex.getStatistics().getNumberOfValues()); > assertEquals( > "The put that caused the exception must be rolled back, it should not > be present in the region", > null, region.get(1)); > assertEquals("The region size should reflect that the last put was > unsuccessful", 1, > region.size()); > } > {code} > The code must also consider issues like if eventListeners like beforeCreate > etc are fired off and the create fails. -- This message was sent by Atlassian JIRA (v6.4.14#64029)