Umbraco site dies during content import
# help-with-umbraco
j
Hello Umbracians. I have a site that imports products from an external pim service, I then go through all the imported products and create/update content programatically. The issue i have is that the site will just suddenly die during the import, no errors or exceptions in the logs that tells me anything useful. The amount of products it is able to process also varies, sometimes it goes through all 2000 products without crashing, other times it will crash after 500. Have any of you experiences anything like this, and can point me to a solution?
s
Hi, I guess the first thing you could do (if not done already ) is log/try catch different parts and see what errors/exceptions appear.
k
I got the advice recently to always use Scopes or CoreScopes when modifying content (to help Umbraco manage locks, and avoid recursive locks, which are forbidden). If you're not doing that, maybe it could help.
k
Yes, this is probibly a scope thing - Check you are not wrapping to much work up in a scope, (e.g using a scope and then importing 100's of things, rather the scopes should be around the individual updates, so its not locking the site for any great amoiunt of time, if you lock and then do lots of work, it might work for a bit, but then some other process might try and get a lock and then it can all go a bit wobbly.
k
Anyone of you scopemeisters have any examples of scope best practices? The documentation barely mentions them. I get some hits in the old forum but not sure if relevant. Or is the answer "look at the uSync source code" as always? @User @User @User @User
k
uSync does very little 'normally' with scopes, everything is going via the Umbraco layer . uSync has a deffered scope thing it it, but that is something which pushes notifications to other things to the end of the bulk process, its not the same as when you are doing stuff with a database.
I feel/thing there should be some docs somewhere about it. but for me, the last time i put some code public would be here https://github.com/KevinJump/DoStuffWithUmbraco/tree/v14/main/src/DoStuff.Core/Data . the baseService and baseRepo use scopes against the db, probibly what you are looking for (or close to it)
j
@Harry Gordon wrote a nice article here: https://harrygordon.co.uk/blog/not-thread-safe-obviously/
l
When doind a lot of importing/writing/updating to Umbraco nodes programmatically, we use the BackgroundTaskQueue (https://apidocs.umbraco.com/v9/csharp/api/Umbraco.Cms.Infrastructure.HostedServices.BackgroundTaskQueue.html), that seems to get rid of any scoping issues we were constantly having. Also, another thought; are you hosting on IIS? It's a long shot, but older versions would sometimes just reboot when there were too many file changes (for instance because your index files get updates constantly when importing/changing Umbraco content).
14 Views