Supplied bookmark [FB:kcwQcw6pr0IHR5SzcD5sXAYZawGQ] does not conform to pattern neo4j🔖v1:tx

I am using neo4j 4.2 . I have written a python script which contains lots of queries.
After connecting neo4j bolt client I am getting
Supplied bookmark [FB:kcwQcw6pr0IHR5SzcD5sXAYZawGQ] does not conform to pattern neo4j:bookmark:v1:tx

I tried uninstall neo4j Neobolt and reinstalled neo4j using pip install neo4j again . It was one of the solution in a post regarding to this error. But in my case it is not working . please help me.
My script was running in 3.5 neo4j version using session. run(). but now I have seen session.write.transaction(). and tx.run(). there are lots of changes in. neo4j. 4.2. is it the one. one. the reason of my. problem cause I used session.run and no tx.run() .can y kindly enlighten me that why tx.run() and session.write.transaction() Is working instead of session.run()

Firstly, this looks like you're using a driver v4.2 with a server v3.5 (... does not conform to pattern neo4j:bookmark:v1:tx would not be sent by a 4.2 server, for instance). This is not officially supported. Each driver officially supports 2 version of the server. A driver of v4.2 will work with a server v4.1 and v4.2. Every other server version might, might partially, or might not work at all; there is no guarantee made.

Secondly, I'd like to see a minimal code example that causes this issue. I suspect there might be a bug in there on top of the aforementioned.

@rouven_bauer sorry for late reply here is my working code at 3.5.14 version neo4j. It was working fine. but after upgrading 4.2 version and the driver I am getting the error , here is the node creation code for sample .if you need some more to observe I will provide you later

from timeit import default_timer as timer
import re

from neo4j import GraphDatabase,basic_auth
from os import listdir
from os.path import isfile, join
neo4jUri="bolt://localhost:7687"






graphdriver=GraphDatabase.driver(neo4jUri,auth=basic_auth("neo4j","XXXX"))
nodesourcefolder="/var/lib/neo4j/import/"
def NodeCreate():
    
    begin=timer()
    with graphdriver.session() as session:
        
        for i in nodefiles:
            if (i=="nodes_AGENT_C_20190727.csv"):
                
                agentquery=CreateNodes(i,"AGENT")
                session.run(agentquery)
                print("AGENT node is Created")
            elif(i=="nodes_CUSTOMER_C_20190727.csv"):
                customerquery=CreateNodes(i,"CUSTOMER")
                session.run(customerquery)
                print("CUSTOMER node is created")
            elif(i=="nodes_MERCHANT_C_20190727.csv"):
                merchantquery=CreateNodes(i,"MERCHANT")
                session.run(merchantquery)
                print("MERCHANT NODE is created")
            elif(i=="nodes_ATM_C_20190727.csv"):
                atmquery=CreateNodes(i,"ATM")
                session.run(atmquery)
                print("ATM Node is Created")
            elif(i=="nodes_BANK_C_20190727.csv"):
                bankquery=CreateNodes(i,"BANK")
                session.run(bankquery)
                print("BANK NODE IS CREATED")
            elif(i=="nodes_BILLER_C_20190727.csv"):
                billerquery=CreateNodes(i,"BILLER")
                session.run(billerquery)
                print("BILLER Node is created")
            elif(i=="nodes_CARD_C_20190727.csv"):
                cardquery=CreateNodes(i,"CARD")
                session.run(cardquery)
                print("CARD NODE Is Created")
            elif(i=="nodes_DM_C_20190727.csv"):
                
                disbursmentquery=CreateNodes(i,"DM")
                session.run(disbursmentquery)
                print("Disbursment Node is Created")
            elif(i=="nodes_NON_C_20190727.csv"):
                nonlabelquery=CreateNodes(i,"NONLABEL")
                session.run(nonlabelquery)
                print("Non label node is created")
            elif(i=="nodes_REMITTER_C_20190727.csv"):
                remitterquery=CreateNodes(i,"REMITTER")
                session.run(remitterquery)
                print("REMITTER NODE IS CREATED") 
    session.close()            
    end=timer()
def CreateRelationship(filename,fromlabel,fromnode,tolabel,toNode,relationship):
    
    
    relationquery="""USING PERIODIC COMMIT 100000
                      LOAD CSV WITH HEADERS FROM 'file:///%s' AS row
                      MATCH (a:%s {WALLETID: row.%s})
                      MATCH (c:%s {WALLETID: row.%s})
                      MERGE (a)-[r:%s]->(c)
                      return count(*)"""%(filename,fromlabel,fromnode,tolabel,toNode,relationship)
    return relationquery

NodeCreate()

when I am calling the NodeCreate() function I am getting the error.

I'm not able to reproduce the problem. You could help me getting closer to it by letting me know what CreateNodes() does. But even then, I can't see how this code could cause this error :thinking:

Another hint: session.close() is redundant. The context with driver.session()... handles the lifetime of the session for you.

I've reduced the example to the essential things:

from timeit import default_timer as timer

from neo4j import GraphDatabase,basic_auth


neo4j_uri= "bolt://localhost:7687"

driver=GraphDatabase.driver(neo4j_uri, auth=basic_auth("neo4j", "XXXX"))


def node_create():
    begin = timer()
    with driver.session() as session:
        query = """MERGE (n:`%s`) RETURN n""" % "Nice Label"
        result = session.run(query)
        print(list(result))
        print(result.consume().__dict__)

    end = timer()
    print(end - begin)


if __name__ == "__main__":
    node_create()

Could you try to run this with your setup and see if this causes the same error?
If it doesn't fail, I'd be interested in the output (especially the output of print(result.consume().__dict__). Also, in that case please try to modify my example so that it fails.

@rouven_bauer its my bad I included the create_relationship() function instead of create_node()
it is the the generic node creation query. I will try your code but here is my create_node function which is used into node create function :p . PLEASE HAVE A LOOK

def CreateNodes(filename,label):
    
    
    print(filename,label)
    print(type(filename),type(label))
    path=nodesourcefolder+filename
    print(path)
    print("Type",type(path))
    #filestring=nodesourcefolder+filename
    if(isfile(path)==True):
        print("valid")
        
       
            
            
        nodequery="""CALL apoc.periodic.iterate('CALL apoc.load.csv("%s") yield map as row return row','CREATE (p:%s) SET p = row', {batchSize:1000000, iterateList:true, parallel:true})"""%(path,label)
        #nodequery="""CALL apoc.periodic.iterate('CALL apoc.load.csv("""+path+""") yield map as row return row','CREATE (p:"""+ str(label) +""") SET p = row', {batchSize:10000, iterateList:true, parallel:true})"""

        
        print(nodequery)
        #graphdriver.run(nodequery)
    return nodequery

dear @rouven_bauer ,
I have modified your sample example by this way

def node_create(filename,label):
    begin = timer()
    
    print(filename,label)
    print(type(filename),type(label))
    path=nodesourcefolder+filename
    print(path)
    print("Type",type(path))
    #filestring=nodesourcefolder+filename
    if(isfile(path)==True):
        
        print("valid")
    with driver.session() as session:
        query = """CALL apoc.periodic.iterate('CALL apoc.load.csv("%s") yield map as row return row','MERGE (p:%s) SET p = row', {batchSize:1000000, iterateList:true, parallel:true})"""%(path,label)
        result = session.run(query)
        print(list(result))
        
        print(result.consume().__dict__)

    end = timer()
    print(end - begin)

and then called the main function like this

if __name__ == "__main__":
    node_create('nodes_TEST.csv','TEST')

output is

nodes_TEST.csv TEST
<class 'str'> <class 'str'>
/usr/local/Cellar/neo4j/4.1.1/libexec/import/nodes_TEST.csv
Type <class 'str'>
valid

[<Record batches=1 total=3 timeTaken=0 committedOperations=3 failedOperations=0 failedBatches=0 retries=0 errorMessages={} batch={'total': 1, 'committed': 1, 'failed': 0, 'errors': {}} operations={'total': 3, 'committed': 3, 'failed': 0, 'errors': {}} wasTerminated=False failedParams={}>]
{'metadata': {'query': 'CALL apoc.periodic.iterate('CALL apoc.load.csv("/usr/local/Cellar/neo4j/4.1.1/libexec/import/nodes_TEST.csv") yield map as row return row','MERGE (p:TEST) SET p = row', {batchSize:1000000, iterateList:true, parallel:true})', 'parameters': {}, 'server': <neo4j.api.ServerInfo object at 0x7fb35467a150>, 't_first': 39, 'fields': ['batches', 'total', 'timeTaken', 'committedOperations', 'failedOperations', 'failedBatches', 'retries', 'errorMessages', 'batch', 'operations', 'wasTerminated', 'failedParams'], 'bookmark': 'FB:kcwQ1fL/fDQWQsua6Nc4M3vmEMkB0JA=', 'type': 'rw', 't_last': 651, 'db': 'neo4j'}, 'server': <neo4j.api.ServerInfo object at 0x7fb35467a150>, 'database': 'neo4j', 'query': 'CALL apoc.periodic.iterate('CALL apoc.load.csv("/usr/local/Cellar/neo4j/4.1.1/libexec/import/nodes_TEST.csv") yield map as row return row','MERGE (p:TEST) SET p = row', {batchSize:1000000, iterateList:true, parallel:true})', 'parameters': {}, 'query_type': 'rw', 'plan': None, 'profile': None, 'notifications': None, 'counters': {}, 'result_available_after': 39, 'result_consumed_after': 651}
0.7010458620000009

the TEST.csv file is

ID,NAME
123,abc
983,bcd
771,dfda

I have got only 771,dfda entry in TEST Node

and it is in my local pc which has actually 4.1.1 version . my EC2 instance version is 4.2.

After having a chat with a colleague that has been around longer than me, this could also be a compatibility issue between the driver version and the server version. If you're running server versions 4.1.1 and 4.2, please make sure your driver is at least version 4.2. It's also worth trying driver version 4.3. Even though server version 4.1 is not officially supported with the latest driver, it's still likely to work.

rouven , thanks a lot . I changed driver into 4.3.1 it has worked. with my instance neo4j version 4.2 :slight_smile: