question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SDK hangs when server is unreachable

See original GitHub issue

Describe the bug I am using v3.9.1 and testing this against a local emulator.

I wanted to test how our code behaves in face of network partitions. Therefore, I reproduced a situation where the client is successfully initialized but before executing a transactional batch, the server is shut down. The result is that ExecuteAsync hangs.

To Reproduce

async Task Main()
{
    var connectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=<account key>";
    
    var clientBuilder = new CosmosClientBuilder(connectionString);
    var clientWithSerialization = clientBuilder.WithSerializerOptions(new CosmosSerializationOptions
    {
        PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase
    });
    var containerProperties = new ContainerProperties
    {
        Id = "testcontainer",
        PartitionKeyPath = $"/partitionKey"
    };
    
    var client = clientWithSerialization.Build();
    var database = (await client.CreateDatabaseIfNotExistsAsync("test")).Database;
    var container = (await database.CreateContainerIfNotExistsAsync(containerProperties)).Container;
        
    var item = new Item
    {
        PartitionKey = "abc"
    };

    var batch = container.CreateTransactionalBatch(new PartitionKey(item.PartitionKey));
    batch.CreateItem(item);

    // Put a breakpoint here and before continuing, shut the server down
    var response = await batch.ExecuteAsync();
}

Expected behavior

  • ExecuteAsync returns TransactionalBatchResponse where an error response status is indicated
  • or an exception is thrown

Actual behavior ExecuteAsync never finishes.

Environment summary SDK Version: 3.9.1 OS Version: Windows

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
skurikcommented, Jun 20, 2020

Thank you for the explanation @ealsur, makes sense.

1reaction
skurikcommented, Jun 19, 2020

Using gateway mode did not help.

It reproduces in a 4.7.2 console application: https://github.com/skurik/cosmos-hang

Read more comments on GitHub >

github_iconTop Results From Across the Web

git - Why do I always get the error message "Server is ...
I tried to change the url of github but i can't. I already tried to connect via Tokens but that doesn't work either....
Read more >
bash - Make SSH time out quicker when trying to access ...
It hangs because it waits for your ssh to timeout, it would probably run through if you wait long enough or add a...
Read more >
Crash when initializing SDK with unreachable server
I'm having crashes when trying to initialize the SDK while the server was unreachable - in my case it was because I was...
Read more >
Server unreachable, best way to find out the cause?
During this downtime, the crontabs etc. are running normally and I couldn't find any clou of a crash or related in any logfiles....
Read more >
35996 - 12.1 EDK - SDK "download operation timed out" error
When I download my software application for debugging, the following error message occurs: "download operation timed out." What can I do to work ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found