Source:
<code>private boolean updateIndex(final String indexName, final List<String> fieldNames, final Changes changes, long lastSequence) { if (indexName == null || indexName.isEmpty()) { return false; } <START> Future<Boolean> result = queue.submitTransaction(new SQLQueueCallable<Boolean>() { <END> @Override public Boolean call(SQLDatabase database) { boolean transactionSuccess = true; database.beginTransaction(); for (DocumentRevision rev: changes.getResults()) { String tableName = IndexManager.tableNameForIndex(indexName); database.delete(tableName, " _id = ? ", new String[]{rev.getId()}); if (!rev.isDeleted()) { List<DBParameter> parameters = parametersToIndexRevision(rev, indexName, fieldNames); if (parameters == null) { continue; } for (DBParameter parameter: parameters) { if (parameter != null) { long rowId = database.insert(parameter.tableName, parameter.contentValues); if (rowId < 0) { transactionSuccess = false; } } if (!transactionSuccess) { String msg = String.format("Updating index %s failed.", indexName); logger.log(Level.SEVERE, msg); break; } } } if (!transactionSuccess) { break; } } if (transactionSuccess) { database.setTransactionSuccessful(); } database.endTransaction(); return transactionSuccess; } }); boolean success; try { success = result.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Execution error encountered:", e); success = false; } catch (InterruptedException e) { logger.log(Level.SEVERE, "Execution interrupted error encountered:", e); success = false; } if (success) { success = updateMetadataForIndex(indexName, lastSequence); } return success; }</code><technical_language>this is a SQLQueueCallable submitTransaction is strange calls transaction. I submit handle transaction preferably remove extra transaction calls submitTransaction control transaction (I need throw currently set transactionSuccess=false). moment sets of calls do thing</technical_language>

Target:
private boolean updateIndex(final String indexName, final List<String> fieldNames, final Changes changes, long lastSequence) { if (indexName == null || indexName.isEmpty()) { return false; } Future<Boolean> result = queue.submitTransaction(new SQLQueueCallable<Boolean>() { @Override public Boolean call(SQLDatabase database) { database.beginTransaction(); for (DocumentRevision rev: changes.getResults()) { String tableName = IndexManager.tableNameForIndex(indexName); database.delete(tableName, " _id = ? ", new String[]{rev.getId()}); if (!rev.isDeleted()) { List<DBParameter> parameters = parametersToIndexRevision(rev, indexName, fieldNames); if (parameters == null) { continue; } for (DBParameter parameter: parameters) { if (parameter != null) { long rowId = database.insert(parameter.tableName, parameter.contentValues); if (rowId < 0) { String msg = String.format("Updating index %s failed.", indexName); logger.log(Level.SEVERE, msg); throw new QueryException(msg); } } } } } return true; } }); boolean success; try { success = result.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Execution error encountered:", e); success = false; } catch (InterruptedException e) { logger.log(Level.SEVERE, "Execution interrupted error encountered:", e); success = false; } if (success) { success = updateMetadataForIndex(indexName, lastSequence); } return success; }