Code Monkey home page Code Monkey logo

Comments (10)

ENikS avatar ENikS commented on June 14, 2024

Yes, the whole SynchronizedGetValue() is kind of fishy. I still have very vague idea how it works and why is it required. If you have suggestion how this could be improved I would love to hear it.

from abstractions.

ENikS avatar ENikS commented on June 14, 2024

I did some digging around this issue and looks like the whole design rests on assumption that null is not a valid resolved value. So, theoretically it should never return 'null' if value had been resolved.

from abstractions.

ENikS avatar ENikS commented on June 14, 2024

Closing for now, feel free to reopen if you've got any ideas how to improve the implementation.

from abstractions.

owerkop avatar owerkop commented on June 14, 2024

@ENikS
We have such problem on our production environment. Sometimes our application stucks on Monitor.Enter.
What would You say to implement (change SynchronizedLifetimeManager) some kind of workaround:

public override object GetValue()
{    
  TimeSpan someBigEnoughTimeout = ...
  if(Monitor.TryEnter(this.lockObj, someBigEnoughTimeout))    
  {
    object obj2 = this.SynchronizedGetValue();    
    if (obj2 != null)    
    {
      Monitor.Exit(this.lockObj);    
    }    
    return obj2;
  }
  else
  {
     //do recovery as we know we had stucked
     LogError(); //to make it possible to analyze how often the problem occurs
     this.Recover();
     throw new Exception();
  }
}

Do You see any threats?

from abstractions.

ENikS avatar ENikS commented on June 14, 2024

from abstractions.

owerkop avatar owerkop commented on June 14, 2024

I've added throwing exception.
Timeout could be 1 minute. To be sure that we have stucked and minimize false positives eg. when we have very busy cpu.

from abstractions.

ENikS avatar ENikS commented on June 14, 2024

This will be rather big, breaking change

from abstractions.

ENikS avatar ENikS commented on June 14, 2024

You could build locally and try it out.

To use this feature you need to set global timeout like this:

SynchronizedLifetimeManager.ResolveTimeout = 30000; // 30 sec

It will fail with regular ResolutionFailedException and inner exception TimeOutException

If it works as expected I'll cut the release

from abstractions.

smasherprog avatar smasherprog commented on June 14, 2024

We are getting deadlocks on this issue above. If the getvalue locks, whose job is it to setvalue? Seems very bad to leave a lock open like this.
Also, the resolvetimeout isnt a valid fix either unfortunately. This just tries to hide the bug under a pile of poop.
If the container isnt being resolved in any reasonable amount of time, then the application is not usable.

from abstractions.

ENikS avatar ENikS commented on June 14, 2024

In latest version there is a way to set timeout for the lock.

from abstractions.

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.