0
votes

i am using corda os 4.4, and i am trying to use postgresql instead of h2. i managed to get my node running initially after running "gradle clean deployNodes" and "runnodes", but after i shutdown the nodes and try running them again using "gradle clean deployNodes", i see the following error:

[ERROR] 15:01:30+0800 [main] internal.NodeStartupLogging. - Exception during node startup: Private key for the node legal identity not found (alias identity-private-key) but the corresponding public key for it exists in the database. This suggests the identity for this node has been lost. Shutting down to prevent network map issues. [errorCode=r5hpbl, moreInformationAt=https://errors.corda.net/OS/4.4/r5hpbl]

here are the settings for one of my nodes:

 node {
        name "O=test1,L=test2,C=test3"
        p2pPort 10005
        rpcSettings {
            address("localhost:10006")
            adminAddress("localhost:10046")
        }
        rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
        extraConfig = [
                    "dataSourceProperties.dataSourceClassName"  : "org.postgresql.ds.PGSimpleDataSource",
                    "dataSourceProperties.dataSource.url"       : "jdbc:postgresql://localhost:5432/postgres",
                    "dataSourceProperties.dataSource.user"      : "corda-node-test",
                    "dataSourceProperties.dataSource.password"  : "password",
                    "database.transactionIsolationLevel"        : "READ_COMMITTED",
                    "database.initialiseSchema"                 : "true",
                    "jarDirs"                                   : [ "../../../libs" ]
        ]
    }

The only way I can remove this error is to drop the whole schema and recreate them:

DROP SCHEMA "corda-node-test_schema" CASCADE;
CREATE USER "corda-node-test" WITH LOGIN PASSWORD 'password';
CREATE SCHEMA "corda-node-test_schema";
GRANT USAGE, CREATE ON SCHEMA "corda-node-test_schema" TO "corda-node-test";
GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON ALL tables IN SCHEMA "corda-node-test_schema" TO "corda-node-test";
ALTER DEFAULT privileges IN SCHEMA "corda-node-test_schema" GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON tables TO "corda-node-test";
GRANT USAGE, SELECT ON ALL sequences IN SCHEMA "corda-node-test_schema" TO "corda-node-test";
ALTER DEFAULT privileges IN SCHEMA "corda-node-test_schema" GRANT USAGE, SELECT ON sequences TO "corda-node-test";
ALTER ROLE "corda-node-test" SET search_path = "corda-node-test_schema";

but after i start it up, and try to run "gradle clean deployNodes" again, im back to square one. anyone got any ideas or suggestions? Thanks!

1

1 Answers

0
votes

This happens because when you do a clean deploy, the clean command doesn't clean the postgres database, unlike h2 database.

Ideally, in production system, it is expected that you will deploy you cordapp once, later of course you can upgrade your contract, states and flows when required but you will never clean off completely the database completely.

So right now what is happening is when you deploy your cordapp for the first time, certificates are generated by the bootstrapper tool(you can find these in build/nodes/PartyA/certificates folder), they are also saved in the DB.

When you do a clean build, the build folder is cleaned but the database is not cleaned and gets corrupted with the new entries which also has the new entries, and the node is confused with which entry to use.