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

Async/Await not waiting for Subquery Transactions #973

Open
rvazarkar opened this issue Jul 26, 2022 · 1 comment
Open

Async/Await not waiting for Subquery Transactions #973

rvazarkar opened this issue Jul 26, 2022 · 1 comment

Comments

@rvazarkar
Copy link

rvazarkar commented Jul 26, 2022

  • Neo4j version: Community 4.4.4
  • Neo4j Mode: Single instance
  • Driver version: Javascript driver 4.4.6
  • Operating system: Windows 11/WSL2

Steps to reproduce

Run multiple queries that have a CALL { X } in transactions of Y rows in an async/await context. You can see an example here:
https://github.com/BloodHoundAD/BloodHound/blob/5fb2ef87a56b21f6dfa0e324698729d3ff3af739/src/components/Menu/MenuContainer.jsx#L495

  • Expected behavior
    Queries wait for the transaction to be finished before returning from an await
  • Actual behavior
    Transactions appear to still be running in the background, resulting in SharedLock issues
MenuContainer.jsx:692 UNWIND $props AS prop
        CALL {
            WITH prop
            MERGE (n:AZBase {objectid: prop.source}) SET n:AZTenant MERGE (m:AZBase {objectid: prop.target}) SET m:AZApp MERGE (n)-[r:AZContains ]->(m)
        } IN TRANSACTIONS OF 500 ROWS
MenuContainer.jsx:693 Neo4jError: ForsetiClient[transactionId=29372, clientId=97] can't acquire UpdateLock{owners=client: ForsetiClient[transactionId=29372, clientId=97], client: ForsetiClient[transactionId=29373, clientId=88], , refCount=2} on DEGREES(52015), because holders of that lock are waiting for ForsetiClient[transactionId=29372, clientId=97].
 Wait list:SharedLock[
Client[29372] waits for [ForsetiClient[transactionId=29373, clientId=88]], 
Client[29373] waits for [ForsetiClient[transactionId=29372, clientId=97]]]

    at captureStacktrace (webpack:///./node_modules/neo4j-driver-core/lib/result.js?:239:17)
    at new Result (webpack:///./node_modules/neo4j-driver-core/lib/result.js?:59:23)
    at Session._run (webpack:///./node_modules/neo4j-driver-core/lib/session.js?:174:16)
    at Session.run (webpack:///./node_modules/neo4j-driver-core/lib/session.js?:139:21)
    at _callee6$ (webpack:///./src/components/Menu/MenuContainer.jsx?:689:30)
    at tryCatch (webpack:///./src/components/Menu/MenuContainer.jsx?:44:2404)
    at Generator.eval [as _invoke] (webpack:///./src/components/Menu/MenuContainer.jsx?:44:1964)
    at Generator.eval [as next] (webpack:///./src/components/Menu/MenuContainer.jsx?:44:3255)

Note that the query being run isn't even in the post-processing section, and is instead a query from the file upload that was being performed before post-processing runs (which also uses async/await). Relevant code is here

@bigmontz
Copy link
Contributor

@rvazarkar, I could not find the query

UNWIND $props AS prop
        CALL {
            WITH prop
            MERGE (n:AZBase {objectid: prop.source}) SET n:AZTenant MERGE (m:AZBase {objectid: prop.target}) SET m:AZApp MERGE (n)-[r:AZContains ]->(m)
        } IN TRANSACTIONS OF 500 ROWS

in the referred file.

Could you please enable driver logs and reproduce the error in a small snippet?

How to enable logs: https://neo4j.com/docs/javascript-manual/current/client-applications/#js-driver-logging

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

No branches or pull requests

2 participants