TagHistoryManager().queryHistory : java.lang.IllegalArgumentException: Comparison method violates its general contract!

Ignition 8.1.0

I use TagHistoryManager().queryHistory to retrieve some history data from a module (gateway scope)

Sometimes, I have the following exception:

ResultWriter	03Dec2020 16:20:20	Error executing historical tag read.
java.lang.IllegalArgumentException: Comparison method violates its general contract!

what does it mean ?

            BasicTagHistoryQueryParams tagHistoryQueryParams = new BasicTagHistoryQueryParams();
            // /!\ Flag.and() doesn't mutate the object, it returns a new one
            Flags flags = Flags.of(TagHistoryQueryFlags.BOUNDING_VALUES_YES,
                    TagHistoryQueryFlags.NO_INTERPOLATION,
                    TagHistoryQueryFlags.NO_SCANCLASS_VALIDATION,
                    TagHistoryQueryFlags.NO_CACHE,
                    TagHistoryQueryFlags.NO_PREPROCESSED_DATA);

            tagHistoryQueryParams.setQueryFlags(flags);
            tagHistoryQueryParams.setReturnSize(-1);
            tagHistoryQueryParams.setAggregationMode(AggregationMode.LastValue);
            tagHistoryQueryParams.setStartDate(startDate);
            tagHistoryQueryParams.setEndDate(endDate);
            // Tall : Column format is fixed at "path, value, quality, timestamp".
            tagHistoryQueryParams.setReturnFormat(ReturnFormat.Tall);
            tagHistoryQueryParams.setPaths(paths);
            BasicStreamingDataset streamingDataset = new BasicStreamingDataset();
            logger.debug("queryHistoryDataChanges() - begin");

            this.gatewayContext.getTagHistoryManager().queryHistory(tagHistoryQueryParams, streamingDataset);
ResultWriter	03Dec2020 16:20:20	Error executing historical tag read.
java.lang.IllegalArgumentException: Comparison method violates its general contract!

at java.base/java.util.ComparableTimSort.mergeHi(Unknown Source)

at java.base/java.util.ComparableTimSort.mergeAt(Unknown Source)

at java.base/java.util.ComparableTimSort.mergeCollapse(Unknown Source)

at java.base/java.util.ComparableTimSort.sort(Unknown Source)

at java.base/java.util.Arrays.sort(Unknown Source)

at java.base/java.util.Arrays.sort(Unknown Source)

at java.base/java.util.ArrayList.sort(Unknown Source)

at java.base/java.util.Collections.sort(Unknown Source)

at com.inductiveautomation.gateway.tags.history.query.DatasourceQueryExecutor.runSpecialValueQuery(DatasourceQueryExecutor.java:864)

at com.inductiveautomation.gateway.tags.history.query.DatasourceQueryExecutor.readSeedValues(DatasourceQueryExecutor.java:699)

at com.inductiveautomation.gateway.tags.history.query.DatasourceQueryExecutor.primeRead(DatasourceQueryExecutor.java:885)

at com.inductiveautomation.ignition.gateway.sqltags.history.query.AbstractHistoryLoader.startReading(AbstractHistoryLoader.java:118)

at com.inductiveautomation.ignition.gateway.sqltags.history.query.AggregateHistoryQueryExecutor.startReading(AggregateHistoryQueryExecutor.java:85)

at com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryWriter.readData(HistoryWriter.java:312)

at com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryWriter.execute(HistoryWriter.java:230)

at com.inductiveautomation.ignition.gateway.sqltags.history.TagHistoryManagerImpl.queryHistory(TagHistoryManagerImpl.java:538)

at com.bouyguesenergiesservices.ignition.gateway.replay.tag.QueryHistoryTall.queryHistoryDataChanges(QueryHistoryTall.java:1108)

at com.bouyguesenergiesservices.ignition.gateway.replay.tag.QueryHistoryTall.queryHistory(QueryHistoryTall.java:886)

at com.bouyguesenergiesservices.ignition.gateway.replay.tag.QueryHistoryTall.lambda$queryHistoryAsync$0(QueryHistoryTall.java:170)

at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source)

at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)

at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)

at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)

at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)

I think this is a bug on our side. Not sure there’s anything you can do to fix it. I’ll make a ticket…

thanks, I stay tuned.

Did you find anything ?

The ticket has been designated to be picked up “next sprint”. I don’t have any more details about it.

1 Like

This is fixed in 8.1.2.

1 Like

what if you can’t switch from 8.1.0?

any insight on how to make it either happen less often, or avoid it?
I have a report using a historian query, and just that page is giving me the error of comparison method violates its general contract.
@PGriffith

broke on Sunday, had been working

Then you can't get fixes. Upgrades contain bug fixes. No upgrade, no bug fix.

Sometimes there are work-arounds, sometimes not. As noted above, this is one of the unfortunate "nots".

1 Like

I am going to avoid the simple table in reports for now, as it seems like the only thing that broke. (8.1.0)
I don’t know if it uses the history manager in a similar manner.
Other pages were not impacted. None of my pages use the getTagHistoryManager() function afaik.
I think a reset of my gateway would temporarily fix the issue, but I don’t have the ability to do that yet.

Just for my silly curiosity :slight_smile: , but why can't you?

I am too far down the totem pole of my company.
Also, they had paid someone to make a bunch stuff in Ignition, and they don’t want to pay them to fix that stuff if it breaks upgrading probably.