Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Preview] Error log while trying to save scripts into the script table #383

Open
Sotatek-HuyLe3a opened this issue Oct 16, 2024 · 0 comments
Assignees

Comments

@Sotatek-HuyLe3a
Copy link
Collaborator

Error occurs in preview syncing:

Caused by: java.sql.BatchUpdateException: Batch entry 9 insert into script (script_hash, script_type, content, create_datetime, update_datetime) values (NULL, 'NATIVE_SCRIPT', cast('{
  "type" : 0,
  "content" : "{\n  \"type\" : \"atLeast\",\n  \"required\" : -18945,\n  \"scripts\" : [ {\n    \"type\" : \"any\",\n    \"scripts\" : [ {\n      \"type\" : \"sig\",\n      \"keyHash\" : \"1c12f03c1ef2e935acc35ec2e6f96c650fd3bfba3e96550504d53361\"\n    }, {\n      \"type\" : \"atLeast\",\n      \"required\" : -608358,\n      \"scripts\" : [ {\n        \"type\" : \"before\",\n        \"slot\" : 349715\n      } ]\n    } ]\n  }, {\n    \"type\" : \"before\",\n    \"slot\" : 253254\n  }, {\n    \"type\" : \"atLeast\",\n    \"required\" : 299445,\n    \"scripts\" : [ {\n      \"type\" : \"after\",\n      \"slot\" : 318469\n    } ]\n  }, {\n    \"type\" : \"all\",\n    \"scripts\" : [ ]\n  }, {\n    \"type\" : \"all\",\n    \"scripts\" : [ ]\n  } ]\n}"
}' as json), cast('2024-10-16 14:04:53.665088+07' as timestamp(6)), cast('2024-10-16 14:04:53.665088+07' as timestamp(6))) on conflict do nothing was aborted: ERROR: null value in column "script_hash" of relation "script" violates not-null constraint
  Detail: Failing row contains (null, NATIVE_SCRIPT, {"type": 0, "content": "{\n  \"type\" : \"atLeast\",\n  \"requir..., 2024-10-16 14:04:53.665088, 2024-10-16 14:04:53.665088).  Call getNextException to see other errors in the batch.
	at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:165) ~[postgresql-42.7.1.jar:42.7.1]
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401) ~[postgresql-42.7.1.jar:42.7.1]
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:573) ~[postgresql-42.7.1.jar:42.7.1]
	at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:896) ~[postgresql-42.7.1.jar:42.7.1]
	at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:919) ~[postgresql-42.7.1.jar:42.7.1]
	at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1677) ~[postgresql-42.7.1.jar:42.7.1]
	at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:127) ~[HikariCP-5.0.1.jar:na]
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java) ~[HikariCP-5.0.1.jar:na]
	at org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:122) ~[jooq-3.18.9.jar:na]
	at org.jooq.tools.jdbc.BatchedPreparedStatement.executeBatch(BatchedPreparedStatement.java:215) ~[jooq-3.18.9.jar:na]
	at org.jooq.tools.jdbc.BatchedConnection.executeLastBatch(BatchedConnection.java:122) ~[jooq-3.18.9.jar:na]
	at org.jooq.tools.jdbc.BatchedConnection.close(BatchedConnection.java:264) ~[jooq-3.18.9.jar:na]
	at org.jooq.impl.DefaultDSLContext.lambda$batchedResult$28(DefaultDSLContext.java:2762) ~[jooq-3.18.9.jar:na]
	at org.jooq.impl.DefaultDSLContext.connectionResult(DefaultDSLContext.java:658) ~[jooq-3.18.9.jar:na]
	... 34 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "script_hash" of relation "script" violates not-null constraint
  Detail: Failing row contains (null, NATIVE_SCRIPT, {"type": 0, "content": "{\n  \"type\" : \"atLeast\",\n  \"requir..., 2024-10-16 14:04:53.665088, 2024-10-16 14:04:53.665088).
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2712) ~[postgresql-42.7.1.jar:42.7.1]
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2400) ~[postgresql-42.7.1.jar:42.7.1]
	... 46 common frames omitted

Reason: In the ScriptRefProcessor class, we are trying to serialize it again to get the script hash, but it fails during serialization in the ScriptAtLeast case, resulting in a null script hash, which causes saving the data to fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant