-
Notifications
You must be signed in to change notification settings - Fork 32
Description
The following code is throwing a DataNotFoundException when running the second query. This second query should not be throwing an exception. The first query does have a problem with the continueIndex.
public class Main {
public static void main(String[] args) {
try {
IRODSAccount acct = IRODSAccount.instance("172.19.0.4", 1247, "rods", "rods",
"/tempZone/home/rods", "tempZone", "demoResc");
IRODSFileSystem fsys = IRODSFileSystem.instance();
IRODSAccessObjectFactory factory = fsys.getIRODSAccessObjectFactory();
final boolean distinct = true;
final boolean computeTotalRowCount = true;
// select COLL_NAME
IRODSGenQueryExecutor executor = factory.getIRODSGenQueryExecutor(acct);
IRODSGenQueryBuilder gqlBuilder = new IRODSGenQueryBuilder(distinct, false, computeTotalRowCount, null);
gqlBuilder.addSelectAsGenQueryValue(RodsGenQueryEnum.COL_COLL_NAME);
gqlBuilder.addConditionAsGenQueryField(RodsGenQueryEnum.COL_META_COLL_ATTR_NAME, QueryConditionOperators.EQUAL, "myattr");
IRODSGenQueryFromBuilder gql = gqlBuilder.exportIRODSQueryFromBuilder(2048 /* rows to return */);
IRODSQueryResultSet resultSet = executor.executeIRODSQueryAndCloseResult(gql, 2048);
//System.out.println(resultSet.getFirstResult().getColumn(RodsGenQueryEnum.COL_COLL_NAME.getName()));
// select count(COLL_NAME)
IRODSGenQueryExecutor executorCount = factory.getIRODSGenQueryExecutor(acct);
IRODSGenQueryBuilder gqlBuilderCount = new IRODSGenQueryBuilder(distinct, false, computeTotalRowCount, null);
gqlBuilderCount.addSelectAsAgregateGenQueryValue(RodsGenQueryEnum.COL_COLL_NAME, SelectFieldTypes.COUNT);
gqlBuilderCount.addConditionAsGenQueryField(RodsGenQueryEnum.COL_META_COLL_ATTR_NAME, QueryConditionOperators.EQUAL, "myattr");
IRODSGenQueryFromBuilder gqlCount = gqlBuilderCount.exportIRODSQueryFromBuilder(1 /* rows to return */);
IRODSQueryResultSet resultSetCount = executorCount.executeIRODSQueryAndCloseResult(gqlCount, 0 /* offset */);
final int count = resultSetCount.getFirstResult().getColumnAsIntOrZero(RodsGenQueryEnum.COL_COLL_NAME.getName());
System.out.println("count is " + count);
factory.closeSessionAndEatExceptions();
fsys.closeAndEatExceptions();
} catch (JargonException e) {
e.printStackTrace();
} catch (GenQueryBuilderException e) {
e.printStackTrace();
} catch (JargonQueryException e) {
e.printStackTrace();
}
}
}
Note that the first query runs a select COLL_NAME but has a continueIndex of 2048. (There are not this many rows.) However, the resultSet is not being iterated on at this point.
The second query is a select count(COLL_NAME) and would normally pass but is returning a DataNotFoundException because of the problem in the first query. It seems to me that some error state persists.
Note that if the commented out line with resultSet.getFirstResult() is executed for the first query, the DataNotFoundException would be thrown which makes sense. But since this is not executed, the exception seems to incorrectly be thrown later in a completely different query.
This is related to irods-contrib/metalnx-web#355.
Additional Notes:
- If there are collections that match the query, the exception is not thrown on the count even with the large
continueIndex. - If there are no collections that match the query, but the initial
continueIndexis 0, the exception is not thrown. - Therefore, to reproduce this there must not be any matching collections and the
continueIndexmust be > 0 on the first query.