taylorkelly / BigBrother

GNU General Public License v3.0
29 stars 20 forks source link

Caught exception when rolling back a DELTA_CHEST #58

Open Albuca opened 13 years ago

Albuca commented 13 years ago

When editing the contents of a chest, and then rolling back those changes, the following exception occurs. BB #291 CB #612

2011-04-08 16:10:30 [SEVERE] [BBROTHER] Rollback edit SQL Exception
org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "UPDATE  BBDATA AS BBDATA,[*]    BBUSERS AS USR  SET RBACKED = '1' WHERE  BBDATA.PLAYER = USR.ID AND ACTION IN('0','1','4','12','2','13','15','16','17','19','20') AND USR.NAME IN ('Albuca') AND DATE > '1302278907' AND X < '500' AND X > '490' AND Y < '90' AND Y > '80' AND Z < '529' AND Z > '519' AND WORLD = '0' AND WORLD = '0' AND RBACKED = '0'; "; expected "SET"; SQL statement:
UPDATE  bbdata AS bbdata, bbusers AS usr  SET rbacked = '1' WHERE  bbdata.player = usr.id AND action IN('0','1','4','12','2','13','15','16','17','19','20') AND usr.name IN ('Albuca') AND date > '1302278907' AND x < '500' AND x > '490' AND y < '90' AND y > '80' AND z < '529' AND z > '519' AND world = '0' AND world = '0' AND rbacked = '0'; [42001-153]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.getSyntaxError(DbException.java:192)
at org.h2.command.Parser.read(Parser.java:2737)
at org.h2.command.Parser.parseUpdate(Parser.java:658)
at org.h2.command.Parser.parsePrepared(Parser.java:423)
at org.h2.command.Parser.parse(Parser.java:275)
at org.h2.command.Parser.parse(Parser.java:247)
at org.h2.command.Parser.prepare(Parser.java:201)
at org.h2.command.Parser.prepareCommand(Parser.java:214)
at org.h2.engine.Session.prepareLocal(Session.java:426)
at org.h2.engine.Session.prepareCommand(Session.java:374)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1100)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:243)
at me.taylorkelly.bigbrother.rollback.Rollback$Rollbacker.run(Rollback.java:200)
2011-04-08 16:10:30 [WARNING] [BBROTHER] Caught exception when rolling back a DELTA_CHEST
2011-04-08 16:10:30 [WARNING] [BBROTHER] Caught exception when rolling back a DELTA_CHEST
2011-04-08 16:10:30 [WARNING] [BBROTHER] Caught exception when rolling back a DELTA_CHEST
frozen707 commented 13 years ago

I found the issue, in /src/main/java/me/taylorkelly/bigbrother/datasource/DataBlockSender.java (line 79 at commit 7d18cf5935a59b61b3c4), apparently the author decided to crop the data-field to 150 characters in commit fd398622e1562c31c99b, for a "connection bug fix". This causes a problem every time for DELTA_CHEST because it always saves EVERY slot when a change occurs, if only the changed slots would be saved, the problem would be at least only occur on big changes, but at present it requires 174 characters AT MINIMUM. which causes it to crash at the parser stage when reverting. Also, for some reason the table contains a lot of amount-entries starting with +- and then a number, but when reading the source for the roll-back parser, this seems to be unexpected?

Edit: You can apparently increase the maximum allowed statement size by passing "maxAllowedPacket=??M" (this defaults to the server default, which in turn defaults to 1 megabyte) to the "jdbc:mysql://" connect string (as seen in http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html), the connector probably cannot fragment the statement itself, but leaves that for the network stack to do.