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

Hang when network fails and recovers #70

Open
mjanulaitis opened this issue Oct 21, 2019 · 0 comments
Open

Hang when network fails and recovers #70

mjanulaitis opened this issue Oct 21, 2019 · 0 comments

Comments

@mjanulaitis
Copy link

mjanulaitis commented Oct 21, 2019

I have written a simple test program which exposes a hang in the library. When I open a connection, add a vertex then disable my network the next call to the library hangs indefinitely. If I re-enable the network the library continues to hang. The library should error and/or timeout when there is a network failure.

using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Gremlin.Net.CosmosDb;
using Gremlin.Net.CosmosDb.Structure;

namespace GremlinTest
{
class Program
{
string Endpoint = "[ENDPOINT]";
string DatabaseName = "[DATABASE]";
string CollectionName = "[COLLECTION]";
string AuthKey = "[AUTHKEY]";
GraphClient graphClient;

    static void Main(string[] args)
    {
        new Program(args);
    }

    public Program(string[] args)
    {
        try
        {
            Task.Run(async () =>
            {
                graphClient = GetGraphClient();
                var vertex = await CreateVertex();

                // Drop the network here
                var savedVertex = await GetVertex(vertex.partitionKey, vertex.id);
                Debug.Assert(savedVertex != null);

            })
            .GetAwaiter().GetResult();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }

        Console.WriteLine("Press any key to exit.");
        Console.ReadKey();
    }

    async Task<MyObject> CreateVertex()
    {
        var myObject = new MyObject();
        var g = graphClient.CreateTraversalSource();
        var createCommand = g.AddV(myObject);
        await graphClient.ExecuteAsync(createCommand);

        return myObject;
    }

    async Task<object> GetVertex(string partitionKey, string id)
    {
        var g = graphClient.CreateTraversalSource();
        var queryCommand = g.V(partitionKey, id);

        var result = await graphClient.QueryAsync<object>(queryCommand);
        return result.FirstOrDefault();
    }

    GraphClient GetGraphClient()
    {
        return new GraphClient(Endpoint, DatabaseName, CollectionName, AuthKey);
    }
}

public class MyObject : IVertex
{
    public string id { get; set; } = Guid.NewGuid().ToString("N").ToLower();
    public string partitionKey { get; set; } = "DeadlockTest";
    public string MyValue { get; set; } = "My Test Value";
}

}

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

1 participant