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

ON CONFLICT DO UPDATE command cannot affect row a second time #1374

Closed
jiguantong opened this issue Dec 25, 2024 · 2 comments · Fixed by #1397
Closed

ON CONFLICT DO UPDATE command cannot affect row a second time #1374

jiguantong opened this issue Dec 25, 2024 · 2 comments · Fixed by #1397

Comments

@jiguantong
Copy link

Version

0.4.43 / 0.6.25

Current behavior

ormponder-darwinia  | 2:43:09 AM INFO  app        Indexed 352 events
ormponder-darwinia  | 2:43:10 AM INFO  app        Indexed 457 events
ormponder-darwinia  | 2:43:10 AM INFO  app        Indexed 501 events
ormponder-darwinia  | 2:43:10 AM INFO  app        Indexed 561 events
ormponder-darwinia  | 2:43:10 AM INFO  app        Indexed 633 events
ormponder-darwinia  | 2:43:11 AM INFO  app        Indexed 403 events
ormponder-darwinia  | 2:43:11 AM INFO  app        Indexed 335 events
ormponder-darwinia  | 2:43:11 AM INFO  app        Indexed 360 events
ormponder-darwinia  | 2:43:12 AM INFO  app        Indexed 344 events
ormponder-darwinia  | 2:43:12 AM INFO  app        Indexed 352 events
ormponder-darwinia  | 2:43:12 AM INFO  app        Indexed 345 events
ormponder-darwinia  | 2:43:12 AM INFO  app        Indexed 349 events
ormponder-darwinia  | 2:43:13 AM INFO  app        Indexed 354 events
ormponder-darwinia  | 2:43:13 AM INFO  app        Indexed 349 events
ormponder-darwinia  | 2:43:13 AM INFO  app        Indexed 705 events
ormponder-darwinia  | 2:43:13 AM INFO  app        Indexed 195 events
ormponder-darwinia  | 2:43:27 AM WARN  sync       Failed 'insertLogs' database method after '10' attempts
ormponder-darwinia  | error: ON CONFLICT DO UPDATE command cannot affect row a second time
ormponder-darwinia  |     at /app/node_modules/pg/lib/client.js:535:17
ormponder-darwinia  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
ormponder-darwinia  |     at PostgresConnection.executeQuery (file:///app/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
ormponder-darwinia  |     at PostgresConnection.connection.executeQuery (file:///app/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
ormponder-darwinia  |     at file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
ormponder-darwinia  |     at DefaultConnectionProvider.provideConnection (file:///app/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
ormponder-darwinia  |     at DefaultQueryExecutor.executeQuery (file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
ormponder-darwinia  |     at InsertQueryBuilder.execute (file:///app/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
ormponder-darwinia  |     at file:///app/node_modules/@ponder/core/src/sync-store/index.ts:560:9
ormponder-darwinia  |     at HeadlessKysely.wrap (file:///app/node_modules/@ponder/core/src/database/kysely.ts:42:24)
ormponder-darwinia  |     at PostgresConnection.executeQuery (file:///app/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:41)
ormponder-darwinia  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
ormponder-darwinia  |     at PostgresConnection.connection.executeQuery (file:///app/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
ormponder-darwinia  |     at file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
ormponder-darwinia  |     at DefaultConnectionProvider.provideConnection (file:///app/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
ormponder-darwinia  |     at DefaultQueryExecutor.executeQuery (file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
ormponder-darwinia  |     at InsertQueryBuilder.execute (file:///app/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
ormponder-darwinia  |     at file:///app/node_modules/@ponder/core/src/sync-store/index.ts:560:9
ormponder-darwinia  |     at HeadlessKysely.wrap (file:///app/node_modules/@ponder/core/src/database/kysely.ts:42:24)
ormponder-darwinia  |     at Object.insertLogs (file:///app/node_modules/@ponder/core/src/sync-store/index.ts:542:5)
ormponder-darwinia  | 2:43:27 AM ERROR sync       Fatal error: Unable to sync 'darwinia' from 4944945 to 4944970.
ormponder-darwinia  | error: ON CONFLICT DO UPDATE command cannot affect row a second time
ormponder-darwinia  |     at /app/node_modules/pg/lib/client.js:535:17
ormponder-darwinia  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
ormponder-darwinia  |     at PostgresConnection.executeQuery (file:///app/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
ormponder-darwinia  |     at PostgresConnection.connection.executeQuery (file:///app/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
ormponder-darwinia  |     at file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
ormponder-darwinia  |     at DefaultConnectionProvider.provideConnection (file:///app/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
ormponder-darwinia  |     at DefaultQueryExecutor.executeQuery (file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
ormponder-darwinia  |     at InsertQueryBuilder.execute (file:///app/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
ormponder-darwinia  |     at file:///app/node_modules/@ponder/core/src/sync-store/index.ts:560:9
ormponder-darwinia  |     at HeadlessKysely.wrap (file:///app/node_modules/@ponder/core/src/database/kysely.ts:42:24)
ormponder-darwinia  |     at PostgresConnection.executeQuery (file:///app/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:41)
ormponder-darwinia  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
ormponder-darwinia  |     at PostgresConnection.connection.executeQuery (file:///app/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
ormponder-darwinia  |     at file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
ormponder-darwinia  |     at DefaultConnectionProvider.provideConnection (file:///app/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
ormponder-darwinia  |     at DefaultQueryExecutor.executeQuery (file:///app/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
ormponder-darwinia  |     at InsertQueryBuilder.execute (file:///app/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
ormponder-darwinia  |     at file:///app/node_modules/@ponder/core/src/sync-store/index.ts:560:9
ormponder-darwinia  |     at HeadlessKysely.wrap (file:///app/node_modules/@ponder/core/src/database/kysely.ts:42:24)
ormponder-darwinia  |     at Object.insertLogs (file:///app/node_modules/@ponder/core/src/sync-store/index.ts:542:5)
ormponder-darwinia  | 2:43:27 AM WARN  process    Received fatal error, starting shutdown sequence
ormponder-darwinia  | 2:43:27 AM FATAL process    Finished shutdown sequence, terminating (exit code 1)

Expected behavior

Synchronization successful

Steps to reproduce

https://github.com/ringecosystem/ormponder/blob/guantong/ponder-0.7.17/ponder.schema.ts

Link to repository

https://github.com/ringecosystem/ormponder/blob/guantong/ponder-0.7.17/ponder.schema.ts

Anything else?

No response

@tk-o
Copy link

tk-o commented Jan 4, 2025

Facing the same issue on v0.8.10.

The logs

2:16:57 PM TRACE indexing   Completed indexing function (event="/eth/base/EARegistrarController:NameRegistered", checkpoint=172200934300000000000084530000000017609998000000000000008450000000000000221)
2:16:57 PM INFO  app        Indexed 72 events
2:16:57 PM DEBUG sync       Failed 'insertLogs' database method, retrying after 125 milliseconds
error: ON CONFLICT DO UPDATE command cannot affect row a second time
    at /Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/pg/lib/client.js:535:17
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at PostgresConnection.executeQuery (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
    at PostgresConnection.connection.executeQuery (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
    at file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
    at DefaultConnectionProvider.provideConnection (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
    at DefaultQueryExecutor.executeQuery (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at InsertQueryBuilder.execute (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
    at file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected][email protected]_/node_modules/ponder/src/sync-store/index.ts:317:9
    at HeadlessKysely.wrap (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected][email protected]_/node_modules/ponder/src/database/kysely.ts:42:24)
    at PostgresConnection.executeQuery (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:41)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at PostgresConnection.connection.executeQuery (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
    at file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
    at DefaultConnectionProvider.provideConnection (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
    at DefaultQueryExecutor.executeQuery (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at InsertQueryBuilder.execute (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
    at file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected][email protected]_/node_modules/ponder/src/sync-store/index.ts:317:9
    at HeadlessKysely.wrap (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected][email protected]_/node_modules/ponder/src/database/kysely.ts:42:24)
    at Object.insertLogs (file:///Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected][email protected]_/node_modules/ponder/src/sync-store/index.ts:302:5)

@tk-o
Copy link

tk-o commented Jan 4, 2025

I updated ponder to v0.8.12 to get more detailed RPC logs. Here's the output:

11:11:49 PM TRACE rpc        Received eth_getLogs response (duration=272.234208, params=[{"fromBlock":"0x10cb72c","toBlock":"0x10cb745","topics":[["0x52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2","0x65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af752","0xb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f7","0xaa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe3","0x1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e46","0x448bc014f1536726cf8d54ff3d6481ed3cbc683c2591ca204274009afa09b1a1","0xe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d7578","0x7c69f06bea0bdef565b709e93a147836b0063ba2dd89f02d0b7e8d931e6a6daa","0xc6621ccb8f3f5a04bb6502154b2caf6adf5983fe76dfef1cfc9c42e3579db444","0x52a608b3303a48862d07a73d82fa221318c0027fbbcfb1b2329bface3f19ff2b","0x03528ed0c2a3ebc993b12ce3c16bb382f9c7d88ef7d8a1bf290eaf35955a1207","0x8f15ed4b723ef428f250961da8315675b507046737e19319fc1a4d81bfe87f85"]],"address":["0xc6d566a56a1aff6508b41f6c90ff131615583bcd","0xc6d566a56a1aff6508b41f6c90ff131615583bcd","0xc6d566a56a1aff6508b41f6c90ff131615583bcd","0xc6d566a56a1aff6508b41f6c90ff131615583bcd","0xc6d566a56a1aff6508b41f6c90ff131615583bcd"]}])
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf1.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf2.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf3.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf7.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf1.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf2.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf3.
11:11:49 PM WARN  sync       Detected invalid eth_getLogs response. Duplicate log for block 0x04ec9940dcf5c789e9c66bcaabc0891d31af6ddf6cbfe3fbcb753da5d9da178a with index 0xf7.
11:11:49 PM TRACE rpc        Sent eth_getBlockByNumber request (params=["0x10cb730",true])
11:11:50 PM TRACE rpc        Received eth_getBlockByNumber response (duration=262.16225, params=["0x10cb730",true])
11:11:50 PM DEBUG sync       Failed 'insertLogs' database method, retrying after 125 milliseconds
error: ON CONFLICT DO UPDATE command cannot affect row a second time
    at /Users/tko/dev/github/namehash/ens-multichain-indexer/node_modules/.pnpm/[email protected]/node_modules/pg/lib/client.js:535:17

@kyscott18 kyscott18 linked a pull request Jan 5, 2025 that will close this issue
@github-project-automation github-project-automation bot moved this from Todo to Done in Ponder Roadmap Jan 5, 2025
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

Successfully merging a pull request may close this issue.

2 participants