0
votes

I am trying to build a new cordapp. And the build is failing for one of my nodes creation, below is the stacktrace in the node respective log

[1;31m[ERROR] 09:25:18+0530 [main] spi.SqlExceptionHelper.logExceptions - ERROR: relation "hibernate_sequence" does not exist
  Position: 17
[m[1;31m[ERROR] 09:25:19+0530 [main] internal.Node.run - Exception during node startup
[m javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:886) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:860) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at net.corda.node.services.network.PersistentNetworkMapCache.updateInfoDB(PersistentNetworkMapCache.ktI247) ~[corda-node-3.3-corda.jar:?]

If i create hibernate_sequence in the db directly then i do not see this error. This error occurs with Postgres DB.

The postgres driver is added in the build.gradle as,

implementation("org.postgresql:postgresql:42.1.4")

The node is configured to use postgres by updating task deployNodes() in build.gradle for the corresponding node, example,

node {
        name "O=LedgerApp,L=London,C=GB"
        ......
        extraConfig = [
                'dataSourceProperties': [
                        'dataSourceClassName': 'org.postgresql.ds.PGSimpleDataSource',
                        '"dataSource.url"'     : 'jdbc:postgresql://localhost:5432/postgres?currentSchema=appschema',
                        '"dataSource.user"'    : 'corda',
                        '"dataSource.password"': 'corda'
                ],
                'database'            : [
                        'transactionIsolationLevel': 'READ_COMMITTED'
                ]
        ]
    }

Corda version used is 3.3-corda.

2

2 Answers

0
votes

This appears to be a bug. hibernate_sequence is the first thing that Hibernate creates when it starts, if it does not exist in the database already.

I've raised an issue here: https://r3-cev.atlassian.net/browse/CORDA-2393.

0
votes

If your PostgresSQL database is hosting multiple schema instances for different Corda Open Source nodes, you will need to create a hibernate_sequence sequence object manually for each subsequent schema added after the first instance. Corda OS doesn't provision Hibernate with a schema namespace setting and a sequence object may be not created.

Run the DDL statement and replace my_schema with your schema namespace:

CREATE SEQUENCE my_schema.hibernate_sequence INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 8 CACHE 1 NO CYCLE;