system.tag.queryTagHistory issue (using Ignition 7.9.4)

I use the system.tag.queryTagHistory to retrieve data (time span 15 seconds) for a number of tagpaths (preferrable 300 tagpaths at once), but when using more then 82 tagpaths I get a gateway exception:

Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: The maximum row limit (1501) has been reached for this query.
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:332)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:306)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runTagHistoryQuery(GatewayInterface.java:715)
at com.inductiveautomation.ignition.client.script.ClientTagUtilities.queryTagHistoryImpl(ClientTagUtilities.java:317)
at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.queryTagHistory(AbstractTagUtilities.java:538)
at sun.reflect.GeneratedMethodAccessor336.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:186)

First I thought the time span was the issue but it is not.

The returned dataset is saved as a csv file. So what is causing this exception and is there a setting / parameter / fix to avoid it?

TIA,
Jan

Nobody knows what is causing the exception and how to solve it?

TIA

What version of Ignition are you using? Also, are there any errors being logged to the gateway console when you run this script?

I’am using version 7.9.4 and tested it with version 7.9.5 as well.

This is the corresponding gateway logging, using 130 tags (the maximum row limit of 45001 is when the time span is 15 seconds, when lowering the time span to 1 second the maximum row limit becomes 1501):

INFO | jvm 1 | 2017/12/04 08:25:31 | E [T.H.Q.ResultWriter ] [07:25:31]: Error executing historical tag read. request-origin=10.0.0.174, session-user=Service, session-project=HitecPowerProtection_V001, session-id=2AC58739, queryid=8ba0ae9d
INFO | jvm 1 | 2017/12/04 08:25:31 | java.lang.IllegalStateException: The maximum row limit (45001) has been reached for this query.
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryWriter.incrementRowCount(HistoryWriter.java:164)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryWriter.commitRows(HistoryWriter.java:374)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryWriter.readData(HistoryWriter.java:316)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryWriter.execute(HistoryWriter.java:230)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.sqltags.SQLTagsManagerImpl.queryHistory(SQLTagsManagerImpl.java:1297)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.project.ProjectSettingsCache$ProjectDefaultTagManagerFacade.queryHistory(ProjectSettingsCache.java:666)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.servlets.gateway.functions.QueryTagHistory.invoke(QueryTagHistory.java:96)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:405)
INFO | jvm 1 | 2017/12/04 08:25:31 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
INFO | jvm 1 | 2017/12/04 08:25:31 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
INFO | jvm 1 | 2017/12/04 08:25:31 | at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(MapServlet.java:85)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:837)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.Server.handle(Server.java:518)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
INFO | jvm 1 | 2017/12/04 08:25:31 | at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
INFO | jvm 1 | 2017/12/04 08:25:31 | at java.lang.Thread.run(Unknown Source)

Still nobody knows what is causing the exception and how to solve it?

TIA

When the history writer is instantiated it sets the maximum row limit based on the query parameters.

I don’t fully understand everything happening with the HistoryWriter or why the return limit is defined this way, but it’s a good place to start tinkering. It would probably be a very bad idea to update the gateway jar yourself to set this limit to the max long value of 2147483647L.