Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Apr 25, 2018 @ 15:08
    Nik
    0

    Removing a property from large quantities of pages

    Hi All,

    I'm hoping for some advice/help with a task. I nearly wrote small task, but it's only small in theory.

    I'm trying to remove properties that are left over on some document types. The problem is, there are 100's / 1000's of each instance of these document types.

    In my scenario I'm trying to delete the property from a document type (straight forward enough, you go into the document type, remove the property, and save it).

    However, no matter what environment I try this on, I'm getting a SQL Transaction error.

    This is the error that is being thrown: "System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding"

    Now, the error makes sense, it's a large operation and it's timing out. However, what I don't know if how I can increase the SQL timeout used within Umbraco as it is the core services that are hitting the database.

    The same error gets thrown if I use uSync to try and remove the property.

    Ideally, I don't really want to have to attack the database directly, I'd love to be able to use Umbraco's default behaviour to achieve this so any ideas on how to achieve it would be delightful.

    (The site has over 8,000 pages)

    Thanks

    Nik

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Apr 26, 2018 @ 12:32
    Dan Diplo
    1

    Tricky! Presumably this delete operation is working in the context of a transaction that is getting rolled back when it doesn't complete due to the timeout?

    I've no idea if this will help, but you can set a value for:

    ApplicationContext.DatabaseContext.Database.CommandTimeout

    So you could try setting this somewhere and seeing if it applies? I'm not sure it will - it may need to be set within the context of a single operation, which you can't control.

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Apr 26, 2018 @ 14:13
    Nik
    101

    Hey Dan,

    I managed to come across a solution that works for Umbraco v 7.4+ This little gem seems to be doing the job:

    https://stackoverflow.com/questions/34241573/how-to-enlarge-tree-timeout-in-umbraco

    Despite the fact that normally adding Connection Timeout to your connection string should only impact the connection, not the querying. It looks like Umbraco takes this value and uses it to help with transaction timeouts as well which is great.

    (Found this today, just hadn't had a time to apply it as a solution yet).

    I suspect that under the hood it is doing exactly what you are suggesting.

    Nik

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Apr 26, 2018 @ 18:54
    Dan Diplo
    1

    Hey Nik, glad you found a solution! I also learnt something new myself - that's definitely handy to know.

Please Sign in or register to post replies

Write your reply to:

Draft