Skip to content

Limit on number of statements exceeded #84

@buzzia2001

Description

@buzzia2001

Good morning,
Every now and then, I encounter the error mentioned in the issue title. According to the documentation, I see that the problem occurs when the job is processing more than 9,999 statements.
In my scenario, the application uses a pool of 15 jobs. Here is the code snippet I use to run the queries:

public ArrayList<HashMap<String,Object>> runQuery(boolean isServer1, String sql){
        Pool mypPool = isServer1 ? server1 : server2;
        ArrayList<HashMap<String,Object>> output = new ArrayList<>();
        
        try {
            Query query = mypPool.query(sql);
            QueryResult<Object> result = query.execute(100).get();

            // Convert each row from QueryResult to HashMap
            List<Object> data = result.getData();

            while (!result.getIsDone()) {
                result = query.fetchMore(100).get();
                data.addAll(result.getData());
            }

            for (Object rowData : data) {
                if (rowData instanceof HashMap) {
                    @SuppressWarnings("unchecked")
                    HashMap<String, Object> row = (HashMap<String, Object>) rowData;
                    output.add(row);
                }
            }            

            query.close().get();
            return output;
        } catch (Exception e) {
            System.out.println("Errore query su "+(isServer1?"server1":"server2")+": "+sql);
            e.printStackTrace();
            return null; 
        }
    }

By using the pool and the statement close function, I expected, first of all, to avoid this scenario, and second, that the jobs would be used equally. From wrkactjob, I can see that some jobs are instantiated but rarely used, while others are used much more frequently.

The current workaround is to close the application and restart it so that it can pick up new jobs, but this causes service disruptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions