QuiltServerTools / DeltaLogger

A block, container and entity logging tool for the fabric mod loader
Other
37 stars 21 forks source link

Insert into placements table fails when block is removed by a mob (creeper explosion, enderman picking up, etc) #71

Open crash-ip21 opened 3 years ago

crash-ip21 commented 3 years ago

Describe the bug Mod tries to insert a row in the table placements of the block removed by a mob, but fails since player_id column is not nullable. Workaround: change a column in the table to be nullable.

Specs:

Logs

[12:48:41] [Thread-202/WARN]: Problem executing batches in handler
[12:48:41] [Thread-202/INFO]: [STDERR]: org.jdbi.v3.core.statement.UnableToExecuteStatementException: org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_NOTNULL]  A NOT NULL constraint failed (NOT NULL constraint failed: placements.player_id) [statement:"INSERT INTO placements (date, placed, x, y, z, state, player_id, type, dimension_id) SELECT :date, :placed, :x, :y, :z, :state, (SELECT id FROM players WHERE uuid=:playeruuid), (SELECT id FROM registry WHERE name=:blockid), (SELECT id FROM registry WHERE name=:dimension_id)", arguments:{positional:{}, named:{date:2021-05-02 12:48:40,blockid:minecraft:sand,placed:false,dimension_id:minecraft:overworld,playeruuid:[REDACTED],x:-312,y:61,z:-39,state:null}, finder:[]}]
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.statement.PreparedBatch.internalBatchExecute(PreparedBatch.java:228)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.statement.PreparedBatch.execute(PreparedBatch.java:107)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at com.github.fabricservertools.deltalogger.DatabaseManager.lambda$processOps$7(DatabaseManager.java:357)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.HandleConsumer.lambda$asCallback$0(HandleConsumer.java:32)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.Jdbi.withHandle(Jdbi.java:341)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.Jdbi.useHandle(Jdbi.java:357)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at com.github.fabricservertools.deltalogger.DatabaseManager.processOps(DatabaseManager.java:331)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at com.github.fabricservertools.deltalogger.DatabaseManager.run(DatabaseManager.java:383)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at java.lang.Thread.run(Thread.java:748)
[12:48:41] [Thread-202/INFO]: [STDERR]: Caused by: org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_NOTNULL]  A NOT NULL constraint failed (NOT NULL constraint failed: placements.player_id)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.sqlite.core.DB.newSQLException(DB.java:1010)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.sqlite.core.DB.newSQLException(DB.java:1022)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.sqlite.core.DB.throwex(DB.java:987)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.sqlite.core.DB.executeBatch(DB.java:812)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.sqlite.core.CorePreparedStatement.executeBatch(CorePreparedStatement.java:72)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.statement.SqlLoggerUtil.wrap(SqlLoggerUtil.java:31)
[12:48:41] [Thread-202/INFO]: [STDERR]:     at org.jdbi.v3.core.statement.PreparedBatch.internalBatchExecute(PreparedBatch.java:220)
[12:48:41] [Thread-202/INFO]: [STDERR]:     ... 8 more
Genau6502 commented 3 years ago

Workaround: change a column in the table to be nullable.

Yeah don't do that, you'll break more than you fix

playeruuid:[Redacted]

Would be useful to know, and there's no reason to redact it

Will take a look now at fixing

crash-ip21 commented 3 years ago

Would be useful to know, and there's no reason to redact it

Sorry, I assumed it was my UUID, but apparently it was ID of a mob entity. My bad. There it is:

df89cbd4-c8a7-4a50-a648-0d650e531c94