0

i get this error when i run it demux postgres the first time . Key (block_number)=(1) already exists. the code abruptly stops. how do i fix this?

dataType:undefined
detail:"Key (block_number)=(1) already exists."
file:"nbtinsert.c"
hint:undefined
internalPosition:undefined
internalQuery:undefined
length:228
line:"535"
message:"duplicate key value violates unique constraint "_block_number_txid_pkey""
name:"error"
position:undefined
routine:"_bt_check_unique"```
0

Seems like it's a postgres-exception forwarded via demux.

The database-record probably already exists in your database - the key already exists, which is why the exception is throwing.

Try to clear the database before each application-start or start your application from a different block (maybe last processed + 1 is a good choice).

const init = async () => {
  const massiveInstance = await massive(dbConfig);
  const actionHandler = new MassiveActionHandler(
    handlerVersions,
    massiveInstance,
    migrationSequences,
    {
      validateBlockHashes: false,
      dbSchema: dbConfig.schema
    }
  );

  const dfuseActionReader = new DfuseActionReader({
    startAtBlock: 50575524,
    onlyIrreversible: true,
    dfuseApiKey: process.env.DFUSE_API_KEY as string,
    query: "account:kmealowner12",
    network: "kylin"
  })
  const actionWatcher = new BaseActionWatcher(dfuseActionReader, 
    actionHandler, {
    logLevel: "trace"
  })
  actionWatcher.watch(true)
}

i am using the newly created dfuseActionReader

  • tried clearing the database. start block is set to 50575524. don't understand why i get (block_number)=(1) – Bhaskar Aug 11 at 1:18
  • can you post some code @Bhaskar? How do you inititalize/start demux? – cmadh Aug 11 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.