HistoricTaskInstanceQuery - effect of limitTaskVariables

When using HistoricTaskInstanceQuery, we found that results sometimes does not contain all task variables, even when query.includeTaskLocalVariables() is specified. This seems to happen more often under heavy load situations.

When explicitly setting query.limitTaskVariables(x) to a large value (> 100000) all expected data is returned.

I would like to understand the behaviour of query.limitTaskVariables(x) - i.e. what the effect of x would be, in order to have confidence in the implementation.