Delete query hangs until restart the server

I'm connecting to the server via bolt. I need to delete all nodes and relations then create a new graph.

Once I run

with driver.session() as session:
    session.run("""CALL apoc.periodic.iterate('MATCH (n) RETURN n', 'DETACH DELETE n', {batchSize:10, parallel:false})""")

Or
result = session.run("""CALL apoc.periodic.commit('MATCH(s) WITH s LIMIT $num DETACH DELETE s RETURN count(*) AS c', {num: 1000})""")

Or
session.run("MATCH (n) DETACH DELETE n")

Then all nodes and relations are deleted, which is right. However, when I run the script again (after creating new nodes and relations), then the query is hung and I have to restart the server so the script is workin.

What is the problem here?
I'm using the latest version of neo4j and I'm facing this issue from different previous versions.

@urvis @Amal

Can you try using the https://neo4j.com/labs/apoc/4.1/overview/apoc.periodic/apoc.periodic.truncate/ ?

This procedure is precisely for this case,

it just execute these 2 apoc.periodic.iterate:

CALL apoc.periodic.iterate("MATCH ()-[r]->() RETURN id(r) as id", "MATCH ()-[r]->() WHERE id(r) = id DELETE r", {config..})

and

CALL apoc.periodic.iterate("MATCH (n) RETURN id(n) as id", "MATCH (n) WHERE id(n) = id DELETE n", {config..})

Did you get any solution ? Facing the same problem.