ISISComputingGroup / IBEX

Top level repository for IBEX stories
5 stars 2 forks source link

Handle Infinity in the archive engine #2955

Open FreddieAkeroyd opened 6 years ago

FreddieAkeroyd commented 6 years ago

If a block has the value "Infinity" then the archive engine throws an exception as this is not valid for MySQL

2018-02-08 13:15:36] 2018-02-08 13:15:36.651 WARNING [Thread 438] org.csstudio.archive.engine.model.WriteThread (run) - Error, will try to reconnect [2018-02-08 13:15:36] java.sql.SQLException: 'Infinity' is not a valid numeric or approximate numeric value

[2018-02-08 13:15:36] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)

[2018-02-08 13:15:36] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)

[2018-02-08 13:15:36] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)

[2018-02-08 13:15:36] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)

[2018-02-08 13:15:36] at com.mysql.jdbc.PreparedStatement.setDouble(PreparedStatement.java:3300)

[2018-02-08 13:15:36] at org.csstudio.archive.writer.rdb.RDBArchiveWriter.batchBlobbedDoubleSample(RDBArchiveWriter.java:320)

[2018-02-08 13:15:36] at org.csstudio.archive.writer.rdb.RDBArchiveWriter.batchDoubleSamples(RDBArchiveWriter.java:295)

[2018-02-08 13:15:36] at org.csstudio.archive.writer.rdb.RDBArchiveWriter.batchSample(RDBArchiveWriter.java:272)

[2018-02-08 13:15:36] at org.csstudio.archive.writer.rdb.RDBArchiveWriter.addSample(RDBArchiveWriter.java:177)

[2018-02-08 13:15:36] at org.csstudio.archive.engine.model.WriteThread.write(WriteThread.java:259)

[2018-02-08 13:15:36] at org.csstudio.archive.engine.model.WriteThread.run(WriteThread.java:182)

[2018-02-08 13:15:36] at java.lang.Thread.run(Unknown Source)

This seemed to lead to some block values not being properly flushed at run start/end when we reload the archive engine. It looks like NaN is Ok as a value, it is not clear if NaN is actually valid in MySQL and as the log value looks to be stored as zero I suspect not. Thus I think the archive engine is trapping NaN already and just needs to trap Infinity too.

It would be worth trapping both "Infinity" and "Inf" as both look to be valid, in theory you can have +Inf and -Inf too...

DominicOram commented 6 years ago

Make sure we feed this change back into CS-Studio

kjwoodsISIS commented 6 years ago

Check new version of the Archive Engine first.

kjwoodsISIS commented 6 years ago

See also 11.2.6 Out-of-Range and Overflow Handling in MySQL (v5.7)