terra-money / fcd-classic

Terra ETL + RestFul API Server
https://fcd.terra.dev/swagger
MIT License
63 stars 42 forks source link

violated not-null constraint for code_id column #136

Closed kamsz closed 2 years ago

kamsz commented 3 years ago

while running a code from bombay branch on bombay network:

10-08 04:53 [INFO]: Trying to run process ProposalCollector
10-08 04:53 [INFO]: Process ProposalCollector starting...
10-08 04:53 [INFO]: Proposal collector started.
10-08 04:53 [INFO]: Checking for deleted proposals
10-08 04:53 [INFO]: Proposal collector completed.
10-08 04:53 [INFO]: Process ProposalCollector ended.
10-08 04:53 [INFO]: collectBlock: begin transaction for block 5902461
10-08 04:53 [INFO]: SaveTxs - txs: 4, accountTxs: 12
10-08 04:53 [INFO]: collectWasm: new contract terra1hgjp2yjqe7ngzsx283tm7ch8xcsvk5c8mdj2tw
10-08 04:53 [ERROR]: null value in column "code_id" of relation "wasm_contract" violates not-null constraint
QueryFailedError: null value in column "code_id" of relation "wasm_contract" violates not-null constraint
    at QueryFailedError.TypeORMError [as constructor] (/app/src/error/TypeORMError.ts:7:9)
    at new QueryFailedError (/app/src/error/QueryFailedError.ts:9:9)
    at PostgresQueryRunner.<anonymous> (/app/src/driver/postgres/PostgresQueryRunner.ts:258:19)
    at step (/app/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
    at Object.throw (/app/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
    at rejected (/app/node_modules/typeorm/node_modules/tslib/tslib.js:115:69)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
hanjukim commented 2 years ago

I think your SQL database is corrupted or not migrated for some reason. Since we are /v1/wasm endpoint dependencies from all of our apps. I think you can safely remove non null constraint from the wasm_contract scheme. ALTER TABLE wasm_contract ALTER COLUMN code_id DROP NOT NULL;

kamsz commented 2 years ago

@hanjukim not sure if that's safe sadly, after few days fcd api starts failing with:

8
QueryFailedError: column "code_id" contains null values
37
    at QueryFailedError.TypeORMError [as constructor] (/fcd/src/error/TypeORMError.ts:7:9)
36
    at new QueryFailedError (/fcd/src/error/QueryFailedError.ts:9:9)
35
    at PostgresQueryRunner.<anonymous> (/fcd/src/driver/postgres/PostgresQueryRunner.ts:247:19)
34
    at step (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
33
    at Object.throw (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
32
    at rejected (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:115:69)
31
    at processImmediate (node:internal/timers:464:21)
30
From previous event:
29
    at __awaiter (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:113:16)
28
    at PostgresQueryRunner.changeColumns (/fcd/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:1358:38)
27
    at /fcd/src/schema-builder/RdbmsSchemaBuilder.ts:635:36
26
    at step (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
25
    at Object.next (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
24
    at step (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:128:143)
23
    at Object.next (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
22
    at fulfilled (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:114:62)
21
From previous event:
20
    at step (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:116:95)
19
    at /fcd/node_modules/typeorm/node_modules/tslib/tslib.js:117:13
18
From previous event:
17
    at __awaiter (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:113:16)
16
    at RdbmsSchemaBuilder.updateExistColumns (/fcd/node_modules/typeorm/schema-builder/RdbmsSchemaBuilder.js:1184:38)
15
    at RdbmsSchemaBuilder.<anonymous> (/fcd/src/schema-builder/RdbmsSchemaBuilder.ts:187:20)
14
    at step (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
13
    at Object.next (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
12
    at fulfilled (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:114:62)
11
From previous event:
10
    at step (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:116:95)
9
    at /fcd/node_modules/typeorm/node_modules/tslib/tslib.js:117:13
8
From previous event:
7
    at __awaiter (/fcd/node_modules/typeorm/node_modules/tslib/tslib.js:113:16)
6
    at createConnection (/fcd/node_modules/typeorm/globals.js:55:34)
5
    at initConnection (/fcd/src/orm/index.ts:108:26)
4
    at processImmediate (node:internal/timers:464:21)
3
From previous event:
2
    at init (/fcd/src/orm/index.ts:148:21)
1
    at async createServer (/fcd/src/server.ts:29:3)