private synchronized ListenableFuture<?> updateUserMemory(String allocationTag, long delta)
    {
        if (delta >= 0) {
            enforceUserMemoryLimit(queryMemoryContext.getUserMemory(), delta, maxUserMemory);
            return memoryPool.reserve(queryId, allocationTag, delta);
        }
        memoryPool.free(queryId, allocationTag, -delta);
        return NOT_BLOCKED;
    }
private synchronized ListenableFuture < ? > updateUserMemory ( String allocationTag , long delta ) { if ( delta >= 0 ) { enforceUserMemoryLimit ( queryMemoryContext . getUserMemory ( ) , delta , maxUserMemory ) ; return memoryPool . reserve ( queryId , allocationTag , delta ) ; } memoryPool . free ( queryId , allocationTag , - delta ) ; return NOT_BLOCKED ; }
Deadlock is possible for concurrent user and system allocations when updateSystemMemory()/updateUserMemory
calls queryMemoryContext.getUserMemory()/queryMemoryContext.getSystemMemory(), respectively.

@see this##updateSystemMemory(long) for details.