Skip to content

[Bug] Neo4jError: Ignored either because of an error or RESET #1080

Open
@gchicoye

Description

@gchicoye

Bug Report

While updating my Neo4J database (community edition) with the following script

const upsertPromiseArrayCreator = (dbEntries:DbEntry[], tx:ManagedTransaction)
:Promise<QueryResult>[] => dbEntries
  .filter((dbEntry) => dbEntry.action === 'UPSERT')
  .map((dbEntry) => new Promise((resolve, reject) => {
    tx.run(
      `
        MERGE (user:User{first_id: $userId })
        ON CREATE SET user.created_at = timestamp()
        ON MATCH SET user.updated_at = timestamp()
        MERGE (audience:Audience{mediarithmics_id:  $segmentId })
        ON CREATE SET audience.created_at = timestamp()
        ON MATCH SET audience.updated_at = timestamp()
        MERGE (user)-[rel:BELONGS_TO]->(audience)
        ON CREATE SET rel.created_at = timestamp()
      `,
      dbEntry,
    )
      .then((result) => resolve(result))
      .catch((e) => {
        // eslint-disable-next-line no-console
        console.log('upsertPromiseArrayCreator error');
        reject((e as Error).message);
      });
  }));

const deletePromiseArrayCreator = (dbEntries:DbEntry[], tx:ManagedTransaction)
:Promise<QueryResult>[] => dbEntries
  .filter((dbEntry) => dbEntry.action === 'DELETE')
  .map((dbEntry) => new Promise((resolve, reject) => {
    tx.run(
      `MATCH (user:User{first_id:$userId})-[belong:BELONGS_TO]->(audience:Audience{mediarithmics_id: $segmentId})
        DELETE belong`,
      dbEntry,
    )
      .then((result) => resolve(result))
      .catch((e) => {
        // eslint-disable-next-line no-console
        console.log('deletePromiseCreator error');
        reject((e as Error).message);
      });
  }));

export const registerChunk = (dbEntries:DbEntry[])
:Promise<true> => new Promise((resolve, reject) => {
  try {
    const session:Session = driver.session();
    session.executeWrite((tx) => {
      const promises = [
        ...upsertPromiseArrayCreator(dbEntries, tx),
        ...deletePromiseArrayCreator(dbEntries, tx),
      ];
      Promise.all(promises)
        .then(() => {
          session.close();
          mediarithmicsLinesCounter.inc(dbEntries.length);
          resolve(true);
        })
        .catch((e) => {
          session.close();
          // eslint-disable-next-line no-console
          console.log('Error in registerChunk Element', e.message);
          reject((e as Error).message);
        });
    });
  } catch (e) {
    // eslint-disable-next-line no-console
    console.log('Error in registerChunk', (e as Error).message);
    reject((e as Error).message);
  }
});

I get the following uncatchable error.

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Neo4jError: Ignored either because of an error or RESET

    at captureStacktrace (/app/node_modules/neo4j-driver-core/lib/result.js:611:17)
    at new Result (/app/node_modules/neo4j-driver-core/lib/result.js:105:23)
    at finishTransaction (/app/node_modules/neo4j-driver-core/lib/transaction.js:488:12)
    at Object.commit (/app/node_modules/neo4j-driver-core/lib/transaction.js:301:25)
    at Transaction.commit (/app/node_modules/neo4j-driver-core/lib/transaction.js:202:37)
    at TransactionExecutor._handleTransactionWorkSuccess (/app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:155:16)
    at /app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:131:42
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  constructor: [Function: Neo4jError] { isRetriable: [Function (anonymous)] },
  code: 'N/A',
  retriable: false
}

Node.js v18.16.0

On my server, we get the following log

2023-04-20 14:21:47.041+0000 ERROR [bolt-1789] Terminating connection due to unexpected error
org.neo4j.bolt.protocol.error.streaming.BoltStreamingWriteException: Failed to finalize batch: Cannot write result response
        at org.neo4j.bolt.protocol.common.transaction.result.ResultHandler.onFinish(ResultHandler.java:116) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at org.neo4j.bolt.protocol.common.fsm.AbstractStateMachine.after(AbstractStateMachine.java:126) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at org.neo4j.bolt.protocol.common.fsm.AbstractStateMachine.process(AbstractStateMachine.java:99) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at org.neo4j.bolt.protocol.common.connector.connection.AtomicSchedulingConnection.lambda$submit$4(AtomicSchedulingConnection.java:113) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at org.neo4j.bolt.protocol.common.connector.connection.AtomicSchedulingConnection.executeJob(AtomicSchedulingConnection.java:336) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at org.neo4j.bolt.protocol.common.connector.connection.AtomicSchedulingConnection.doExecuteJobs(AtomicSchedulingConnection.java:270) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at org.neo4j.bolt.protocol.common.connector.connection.AtomicSchedulingConnection.executeJobs(AtomicSchedulingConnection.java:212) ~[neo4j-bolt-5.4.0.jar:5.4.0]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: io.netty.channel.unix.Errors$NativeIoException: writevAddresses(..) failed: Broken pipe

My Environment

Javascript Runtime Version: 18.16.0
Driver Version: 5.7.0
Neo4j Version and Edition: docker Neo4j:latest - 5.6 Community edition
Operating System: Debian 10 for Server, node:lts-alpine for Client (18.16.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions