I was getting the above error in my RetrieveMultiple call in case if the number of records returned were more than 50000.
This limit is governed by ‘AggregrateQueryRecordLimit’ column value of Deployment Properties table in MSCRM_CONFIG database.
Updating it resolved the issue for me. (Remember this is unsupported customization)
set IntColumn = 100000
where ColumnName = ‘AggregateQueryRecordLimit’
Hope it helps.