Giter Site home page Giter Site logo

Comments (6)

highlyunavailable avatar highlyunavailable commented on May 27, 2024

@rmul This has been resolved, you should be able to get the new version from https://www.nuget.org/packages/Consul/0.5.2.5 or from this repo.

from consuldotnet.

rmul avatar rmul commented on May 27, 2024

@highlyunavailable I've tested the new version, but now it seems that the sessionrenew is not run; The semaphore gets lost every sessionTTl (10 secs) and then gets re-aquired..

from consuldotnet.

highlyunavailable avatar highlyunavailable commented on May 27, 2024

@rmul I'm not seeing that behavior, actually.

I added a test method that looks like this (I grabbed some of the bits from your code, just to see if it was a weird limit or something causing it):

[TestMethod]
public void Semaphore_AcquireWaitRelease()
{
    const string Name = "XService";
    const string Prefix = Name + "/lock";
    const int Limit = 1;
    var _semaphoreOptions = new SemaphoreOptions(Prefix, Limit) { SessionName = Name + "_Session", SessionTTL = TimeSpan.FromSeconds(10) };
    var c = ClientTest.MakeClient();

    var s = c.Semaphore("test/semaphore", 2);

    s.Acquire(CancellationToken.None);

    Assert.IsTrue(s.IsHeld);
    Thread.Sleep(30000);
    Assert.IsTrue(s.IsHeld);

    Assert.IsTrue(s.IsHeld);

    s.Release();

    Assert.IsFalse(s.IsHeld);
}

with the following Consul output:

    2015/05/26 06:42:37 [DEBUG] http: Request /v1/session/create (2.0014ms)
    2015/05/26 06:42:37 [DEBUG] http: Request /v1/kv/test/semaphore/61b1fd08-652c-b98e-2302-b70d886b9ade?flags=16210313421097356768&acquire=61b1fd08-652c-b98e-2302-b70d886b9ade (2.0011ms)
    2015/05/26 06:42:37 [DEBUG] http: Request /v1/kv/test/semaphore?recurse&wait=15s (0)
    2015/05/26 06:42:37 [DEBUG] http: Request /v1/kv/test/semaphore/.lock?flags=16210313421097356768&cas=10 (999.1µs)
    2015/05/26 06:42:37 [DEBUG] http: Request /v1/kv/test/semaphore?recurse&consistent (0)
    2015/05/26 06:42:45 [DEBUG] http: Request /v1/session/renew/61b1fd08-652c-b98e-2302-b70d886b9ade (0)
    2015/05/26 06:42:52 [DEBUG] http: Request /v1/session/renew/61b1fd08-652c-b98e-2302-b70d886b9ade (0)
    2015/05/26 06:43:07 [DEBUG] http: Request /v1/kv/test/semaphore/.lock (0)
    2015/05/26 06:43:07 [DEBUG] http: Request /v1/kv/test/semaphore/.lock?flags=16210313421097356768&cas=19 (2ms)
    2015/05/26 06:43:07 [DEBUG] http: Request /v1/kv/test/semaphore?recurse&consistent&index=19 (30.003102s)
    2015/05/26 06:43:07 [DEBUG] http: Request /v1/kv/test/semaphore/61b1fd08-652c-b98e-2302-b70d886b9ade (1.0006ms)
    2015/05/26 06:43:22 [DEBUG] consul.state: Session 61b1fd08-652c-b98e-2302-b70d886b9ade TTL expired
    2015/05/26 06:43:22 [DEBUG] consul.state: Invalidating session 61b1fd08-652c-b98e-2302-b70d886b9ade due to session destroy

It's calling Renew twice in there, which to me says it's working.

from consuldotnet.

rmul avatar rmul commented on May 27, 2024

Ok, I'll check my code and see if I can still reproduce

from consuldotnet.

highlyunavailable avatar highlyunavailable commented on May 27, 2024

@rmul It looks like you're using an older version. I cloned a copy of your project and swapped out the consul DLL files with one from my build and it appears to be renewing sessions.

from consuldotnet.

highlyunavailable avatar highlyunavailable commented on May 27, 2024

Fixed by 65b819d - thanks @rmul

Added tests to verify this is fixed for locks as well in ef8b00d

from consuldotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.