Possible bug with C# API

I have been running a server that connects to the event store using the C# API and I noticed sometimes it would crash with the following error. I think it is due to the fact that the connection to event store dropped. Although, shouldn’t the subscription dropped method get called instead of the task crashing like so?

Partial stack trace(Omitted my bits)

at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at EventStore.ClientAPI.EventStoreNodeConnection.SubscribeToAll(Boolean resolveLinkTos, Action2 eventAppeared, Action`3 subscriptionDropped, UserCredentials userCredentials)

Inner Exception

System.ObjectDisposedException

Message : Cannot access a disposed object.
Object name: ‘ES-a372a181-b60f-4af6-b365-8a5bf9418271’.

How can we reproduce this? It should not be accessing a disposed object.

Unfortunately the problem happens randomly so I am not quite sure how to reproduce it. I suspect it is linked to the fact that the Eventstore is unavailable(connectivity issues).

Maybe you could try this: use the subscribetoallfrom method to subscribe from a very old position and while it is playing back, kill the event store instance.

I have not been able to reproduce this.

I am currently using version 2 of the API. Which version did you test it against?

2.0.2 to be exact.

I tested against trunk but am not seeing any changes in this regard either

Can you enable verbose logging and send us the log from the client in this circumstance? We have as yet been unable to reproduce this.

Hi,

I’ve just had this error too - am currently investigating.

I am attempting to get some integration tests running on a Jenkins server. Here are the Jenkins logs (removed company specific stuff):

  Errors and Failures:
EXEC : 1) Test error : SessionRepositoryTests.AllValuesAreRetainedAfterLoading
     System.AggregateException : One or more errors occurred.
    ----> EventStore.ClientAPI.Exceptions.ConnectionClosedException : Connection 'ES-928c7f5f-69e5-4ec0-958d-914d13050f49' was closed.
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
     at EventStoreRepository`1.Save(AggregateRoot aggregate, Boolean doConcurrencyCheck)
     at SessionRepositoryTests.cs:line 46
  --ConnectionClosedException

EXEC : 2) Test error : SessionRepositoryTests.CanSaveAndReload
     System.AggregateException : One or more errors occurred.
    ----> System.ObjectDisposedException : Cannot access a disposed object.
  Object name: 'ES-928c7f5f-69e5-4ec0-958d-914d13050f49'.
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
     at EventStoreRepository`1.Save(AggregateRoot aggregate, Boolean doConcurrencyCheck)
     at SessionRepositoryTests.cs:line 32
  --ObjectDisposedException

So what I have done is add the 3.0.0RC2 download to the Jenkins box at C:\EventStore-NET. I am then running the following tests from the NUnit runner on the build server:

public class EventStoreTests
    {
        protected IEventStoreConnection InMemoryEventStore;

#if Build
        private const string EventStorePath = @"C:\EventStore-NET\EventStore.SingleNode.exe";
#else
        private const string EventStorePath = @"C:\EventStore-V3-Debug\EventStore.SingleNode.exe";
#endif
        [TestFixtureSetUp]
        public void FixtureSetup()
        {
            Process.Start(EventStorePath, "--mem-db");
            var ipAddress = IPAddress.Parse("127.0.0.1");
            var ipEndPoint = new IPEndPoint(ipAddress, 1113);

            InMemoryEventStore = EventStoreConnection.Create(ipEndPoint);
            InMemoryEventStore.Connect();
        }

        [TestFixtureTearDown]
        public void FixtureTearDown()
        {
            InMemoryEventStore.Close();
        }
    }


Then have a simple "can save and reload" test:

[TestFixture]
    public class SessionRepositoryTests : EventStoreTests
    {
        private SessionEventStoreRepository repo;

        [SetUp]
        public void SetUp()
        {
            repo = new SessionEventStoreRepository(InMemoryEventStore);
        }

        [Test]
        public void CanSaveAndReload()
        {
            var sessionId = Guid.NewGuid();
            var session = new Session(sessionId, "aUserId");
            repo.Save(session);
            var loadedFromEventStore = repo.GetById(sessionId);
 Assert.IsFalse(Object.ReferenceEquals(session, loadedFromEventStore));
            Assert.AreEqual(session.SessionId, loadedFromEventStore.SessionId);
        }


The first time I ran this test it passed.

Now I have the above errors, plus an issue with a file being locked in my Jenkins workspace

Like I say, I am currently investigating this, just thought I'd post it here in case it helps

Tom

p.s  Works On My Machine ;)

Going to try _process.Close(); in the teardown now :slight_smile:

I will try and do that. It does not happen often and in fact we’ve not been getting that in a while.

I think my bug is more to do with the way i am starting the process and using nunit and Jenkins than ES.

Basically my process is not being closed on Jenkins so whilst the build passes once, subsequent builds fail as the EventStore process is still running and has a lock on a dll so Jankins cannot delete the workspace...

Jin I have posted the fix to my problem here: https://groups.google.com/forum/#!topic/event-store/2pWOct7I1ig

  • like i thought, it was just an issue with how I was starting and (not) stopping the process