Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error - Unhandled exception - Write Lock / Read Lock Deadlock

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Error - Unhandled exception - Write Lock / Read Lock Deadlock

    Charts for the active/displayed tab symbol stopped, as if data stopped, but the DOM and chart trader were still operating normally with data for that symbol. Other tabbed symbol charts (not visible) were not affected. When closing the workspace to restart NT, I found the error window hidden behind the workspace (screenshot below). This has happened several times in recent months, always at a very bad time for a NT deadlock. Log and trace files show nothing. What is happening here?

    Click image for larger version

Name:	image.png
Views:	1018
Size:	6.0 KB
ID:	1252099

    #2
    Hello Lancer,

    If there are not any details in the log or trace files around the time when you had seen the message it would be hard to say what might have caused that. This is a general C# error that can be observed in NinjaScript items. You may run into that error when using Invoke rather than InvokeAsync for items that require using a dispatcher.

    If you aren't working on a specific script when you see that and have no information about what is causing the error it would likely be required to try and troubleshoot the platform to find a set of steps that makes the error happen more frequently. That would help to isolate the source of the problem.

    Comment


      #3
      Are you overriding OnRender? If so, you need to check your handling of brushes and similar resources.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Same issue for me since I was forced to upgrade to the version that was released last fall (never saw this before) I just recently upgraded a about a month ago.

        My message I assume is same posted here

        Error: Unhandled exception. Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary use an upgrade lock in place of the read lock.


        Bruce if you have time I am reading your post about the Brushes and I do use an indicator for several years that does have drawing and plots. NOT sure if that could be the issue now on new updates.

        thanks

        Update: I do not have any thing in my code of my indicators with ReadLock or WriteLock
        Last edited by DTSSTS; 05-24-2023, 09:52 AM. Reason: Update to info

        Comment


          #5
          The chart lock ups and error messages typically occur during fast market times when charts are lagging. Never any clues in log or trace files, so where to troubleshoot remains a mystery. If anyone else wants to test if your charts are lagging when you get the error, go here and download and install the ChartLagTime indicator script. Might help troubleshooting.​​

          Comment


            #6
            For me the freezing issues don't seem to be related to fast markets. They happen all day, every day no matter the market conditions. 15-20 freezes per day, requiring restart. Not possible to trade real money so rolled back to 8.0.26 I'm still testing new version on another account to see if I can identify the culprit. No closer to the solution than I was in January 2023 when I first encountered this situation.

            Edit: I should add: zero freezes on 8.0.26

            Comment


              #7
              This continues to be an issue that is always pushed back to 3rd party vendors... One of the most frustrating and infuriating things that come out of Ninjatrader... What are the odds that everyone having this issue has the same setup with the same indicators and what is the common denominator?

              If you want to use 26.1 and CQG there is a workaround... I am currently trading a live money account on 26.1 with no issues... Until Ninjatrader fixes their new database I won't upgrade from the old one where I had no issues... ever... not once... As many other users have...

              Comment


                #8
                Yep, same old same old. I very tentatively went to 27 (resistance against Watch Live button causing lag on my very narrowband connection). But being ‘squeezed’ from all directions to .28 and further to 8.1 with unwanted ‘plans’, logins, licence key migration and prop-firm issues, rescinding static DOM with third-party brokers and the like.

                Notwithstanding the technical problems occurring with new version that remain absent in predecessors, and hollow statements to the effect that Ninjatrader will continue to support User choice, there is a strategic and surreptitious manipulation to drive all Users toward the Dashboard and NinjaBroker model with every new Release in both 8.0 and 8.1 tracks.
                Last edited by brucerobinson; 06-30-2023, 06:18 AM.

                Comment


                  #9
                  Originally posted by brucerobinson View Post
                  Yep, same old same old. I very tentatively went to 27 (resistance against Watch Live button causing lag on my very narrowband connection). But being ‘squeezed’ from all directions to .28 and further to 8.1 with unwanted ‘plans’, logins, licence key migration and prop-firm issues, rescinding static DOM with third-party brokers and the like.

                  Notwithstanding the technical problems occurring with new version that remain absent in predecessors, and hollow statements to the effect that Ninjatrader will continue to support User choice, there is a strategic and surreptitious manipulation to drive all Users toward the Dashboard and NinjaBroker model with every new Release in bot 8.0 and 8.1 tracks.
                  The plan is to remove the desktop... It's obvious for anyone paying attention... A LOT of headaches go away when the desktop platform goes away...

                  Comment


                    #10
                    #brenthilburn - CQG licence workaround you refer to, is this to copy the new certificate to replace the expired one? I’ve seen the thread but also someone said it didn’t work for them so haven’t yet tried it. Meantime using Rithmic but as of today lose AMP

                    Best,

                    Comment


                      #11
                      brucerobinson it works for me. But I use 26.0. No annoying watch button, old logo and no freezing. Tested on Win7 and Win11.


                      Click image for larger version

Name:	2804.png
Views:	795
Size:	34.9 KB
ID:	1258421

                      Comment


                        #12
                        Another thing that can happen is people have a tendency to try to put what symbol they are trading into DisplayName of indicators (I used to do this sometimes and I've seen lots of code of others that does similar things) - but you can't reliably access Instrument.* during DisplayName without risking these kinds of errors e.g. push-pop-imbalanced etc. Developers will code it in there like public override string DisplayName get { return Name.Trim() + " (" + Instrument.MasterInstrument.Name + ")"; } } or something similar, and it will work fine the first time or two they try it, so they'll forget they did this, and one hundred restarts and an NT version or more later it will start to fail, and they'll start a long inquiry with NinjaTrader saying an upgrade broke everything, when in fact, they've been doing something unsupported and unsupportable for months. And you can't try-catch trap this type of situation - when it happens it seems to leave the platform in an unreliable state henceforth. Often, these kinds of things are the fault of developers, but they don't know what they did wrong, so they blame the platform or an update when it's really been broken since they made the bad code and it just doesn't happen to have caught up with them yet.

                        This having been said, the platform DOES have problems. And I've been aggressive in trying to document them and ask for ffixes. But often, coders are coding something that they shouldn't be as well.

                        I mention this because these are some of the many mistakes I've made over the years because a client asked me to do something that wasn't strictly supported and I did it and it seemed to work at first, but only later learned it caused a low-probability failure once in a while or on certain CPUs or on only one kind of graphics card etc. I've learned over the years to code defensively by having had to laboriously track down these kinds of things and eliminate the bad code in order to achieve high reliability.

                        Currently, I have high reliability in every situation I regularly do on both 8.0.28.0 and 8.1.1.7, but everyone's use case is different, and I'm sure there are things I could be doing that would cause it to not be reliable and I'm just not doing them.

                        I do believe NinjaTrader preventing these kinds of crazy error situations should be a very high priority - certainly 100x as high a priority as adding a watch button or changing the colors around or reworking the way the application credentials work - although I realize these are almost certainly mandates from non-developers based on a business marketing plan and not a technical need and obviously, certainly not based on a preponderance of user requests.

                        And it may be that more documentation is needed to clarify what can and cannot be done safely. The impetus is on NinjaTrader to either make everything reliably work or draw a line around the parts that are safe. It would be great if there was a supreme focus on tracking down and stamping out reliability issues with what we have now before moving forward with even more big picture initatives.
                        Last edited by QuantKey_Bruce; 06-30-2023, 07:52 AM.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment


                          #13
                          Today, after almost three weeks of no write lock / read lock error events running 8.1.1.7, this again today as I was mouse-scrolling a chart back a few minutes: "Unhandled exception: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock." All charts displaying the active chart symbol froze. Clicking on a chart tab for another symbol, those charts are unaffected and operate normally. DOM, Market Analyzer, etc.are unaffected. There's been no change to the workspace or running scripts, so nothing new to point to where to start looking. The mystery continues.

                          Comment


                            #14
                            Since upgrading to 8.1.1.7 (from 8.1.1.6) I get the same error "Write lock may not be acquired with read lock held", from time to time, when scrolling the chart. This error cause the chart to freeze. To recover, it requires quitting NT, killing the NT stock process, and restarting NT. I tried removing NT and installing 8.1.1.6, but the error persists.

                            I did check the comment of QuantKey_Bruce regarding changing DisplayName get and referencing Instrument.MasterInstrument.Name or BarsPeriods and verified I am checking everywhere I use it, it is not null. For example
                            Code:
                            public override string DisplayName{ get { return "MyEMA("+Priod+", "
                                         +(Instrument!=null?""+Instrument.FullName:"")
                                         +(BarsPeriods!=null?("("+BarsPeriods[0].ToString()+")"):"")+")"; }}
                            ​
                            So back to my issue, this is the trace file error message has no additional hint.

                            Any idea?
                            2023-08-09 08:38:39:611 Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.
                            2023-08-09 08:38:39:613 System.Threading.LockRecursionException: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.
                            at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLockCore(TimeoutTracker timeout)
                            at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLock(TimeoutTracker timeout)
                            at NinjaTrader.Data.BarsSeries.Dispose()
                            at NinjaTrader.Data.Bars.Dispose(Boolean disposing)
                            at NinjaTrader.Gui.Chart.ChartControl.<>c__Disp layCla ss595_0.<RemoveBars>b__0()
                            at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
                            at System.Windows.Threading.Dispatcher.Invoke(Action callback)
                            at NinjaTrader.Gui.Chart.ChartControl.RemoveBars(Char tBars chartBars)
                            at NinjaTrader.Gui.Chart.ChartControl.RemoveBarsFromB arsArray(ChartBars chartBars)
                            at NinjaTrader.Gui.Chart.ChartControl.RemovePanel(Cha rtPanel panel, Boolean notifyUi)
                            at NinjaTrader.Gui.Chart.ChartControl.Cleanup()
                            at NinjaTrader.Gui.Chart.ChartTab.Cleanup()
                            at NinjaTrader.Gui.Tools.NTWindow.CleanTabs(TabContro l tabControl, Int32 idx)
                            at NinjaTrader.Gui.Tools.NTWindow.OnClosed(EventArgs e)
                            at System.Windows.Window.WmDestroy()
                            at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
                            at System.Windows.Interop.HwndSource.PublicHooksFilte rMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
                            at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
                            at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o)
                            at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs)
                            at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

                            Comment


                              #15
                              Well, you'll notice that in that stack trace, there's no reference to any of your custom NinjaScript (unless there's more to it - if that's all there is) - it's crashing in the process of disposing a bar series in the platform itself. This is a threading problem in NinjaTrader.
                              Bruce DeVault
                              QuantKey Trading Vendor Services
                              NinjaTrader Ecosystem Vendor - QuantKey

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              70 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              143 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              76 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              47 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              51 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X