CodeChain-io / CodeChain-io/codechain-indexer

SequelizeForeignKeyConstraintError when requesting transaction quickly serveral times.

Đang mở
#128 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
21
Fork
15
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The error message following occurs when I request transaction ("/tx") quickly several times.

{ SequelizeForeignKeyConstraintError: update or delete on table "AssetSchemes" violates foreign key constraint "AssetTransferInputs_assetType_fkey" on table "AssetTransferInputs"
at Query.formatError (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/lib/dialects/postgres/query.js:296:16)
at query.catch.err (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/lib/dialects/postgres/query.js:86:18)
at tryCatcher (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:690:18)
at _drainQueueStep (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/home/kodebox/codechain/codechain-indexer/node_modules/sequelize/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:120:23)
name: 'SequelizeForeignKeyConstraintError',
parent:
{ error: update or delete on table "AssetSchemes" violates foreign key constraint "AssetTransferInputs_assetType_fkey" on table "AssetTransferInputs"
at Connection.parseE (/home/kodebox/codechain/codechain-indexer/node_modules/pg/lib/connection.js:554:11)
at Connection.parseMessage (/home/kodebox/codechain/codechain-indexer/node_modules/pg/lib/connection.js:379:19)
at Socket. (/home/kodebox/codechain/codechain-indexer/node_modules/pg/lib/connection.js:119:22)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: 'error',
length: 388,
severity: 'ERROR',
code: '23503',
detail:
'Key (assetType)=(6ed1f013b0bad558266590f9f6a917058ffb4063) is still referenced from table "AssetTransferInputs".',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'AssetTransferInputs',
column: undefined,
dataType: undefined,
constraint: 'AssetTransferInputs_assetType_fkey',
file: 'ri_triggers.c',
line: '3280',
routine: 'ri_ReportViolation',
sql: 'DELETE FROM "Blocks" WHERE "number" = 81' },
original:
{ error: update or delete on table "AssetSchemes" violates foreign key constraint "AssetTransferInputs_assetType_fkey" on table "AssetTransferInputs"
at Connection.parseE (/home/kodebox/codechain/codechain-indexer/node_modules/pg/lib/connection.js:554:11)
at Connection.parseMessage (/home/kodebox/codechain/codechain-indexer/node_modules/pg/lib/connection.js:379:19)
at Socket. (/home/kodebox/codechain/codechain-indexer/node_modules/pg/lib/connection.js:119:22)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: 'error',
length: 388,
severity: 'ERROR',
code: '23503',
detail:
'Key (assetType)=(6ed1f013b0bad558266590f9f6a917058ffb4063) is still referenced from table "AssetTransferInputs".',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'AssetTransferInputs',
column: undefined,
dataType: undefined,
constraint: 'AssetTransferInputs_assetType_fkey',
file: 'ri_triggers.c',
line: '3280',
routine: 'ri_ReportViolation',
sql: 'DELETE FROM "Blocks" WHERE "number" = 81' },
sql: 'DELETE FROM "Blocks" WHERE "number" = 81',
fields: null,
table: 'AssetSchemes',
value: undefined,
index: 'AssetTransferInputs_assetType_fkey',
reltype: undefined }
(node:19211) UnhandledPromiseRejectionWarning: Error: DBError
at Object.exports.DBError (/home/kodebox/codechain/codechain-indexer/src/exception.ts:2:30)
at Object.deleteBlockByNumber (/home/kodebox/codechain/codechain-indexer/src/models/logic/block.ts:188:25)
(node:19211) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:19211) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu từ src/models/logic/block.ts:188 và theo dõi deleteBlockByNumber từ các request đến /tx, sử dụng lỗi DELETE FROM "Blocks" đã được báo cáo làm tín hiệu tái hiện. Tái hiện nhiều request giao dịch nhanh và kiểm tra các mối quan hệ giữa AssetSchemes và AssetTransferInputs. Hoàn tất khi kịch bản request nhanh không còn tạo ra lỗi khóa ngoại hoặc lỗi từ chối promise chưa được xử lý.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
node.js, postgresql, typescript
Lĩnh vực
backend, databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.