Edit Conflicts on Page Save

Help
2009-06-04
2013-05-13
  • White Mystery
    White Mystery
    2009-06-04

    I've got a maintenance bot on a smaller wiki and one of the tasks it performs is a global category replacement.

    As you can guess, this gets used rarely, but recently when trying to use this I get about a 50/50 edit conflict rate when trying to complete this operation - half of the pages save correctly, the other half get an exception with an edit conflict and will not save.

    I have tried:
    - Toggling between Load and LoadEx for the page load
    - Saving individual pages vs saving the entire pagelist with SaveSmoothly
    - Adding in Thread.Sleep statements before and after the load and before and after the save

    and nothing seems to make any difference.

    I hope it's something I'm doing wrong and I would appreciate any feedback anyone might have.

    Thanks in advance!

    The relevant portion of the code (sorry for the formatting):

    (target is a string representing the target category to remove, replacementText is a string representing the new category)

    PageList plLinksToTarget = new PageList(targetSite);

    plLinksToTarget.FillAllFromCategoryTree(target);

    foreach ( Page pLinkToTarget in plLinksToTarget.pages ) {

    try {

    pLinkToTarget.Load();

    pLinkToTarget.RemoveFromCategory(target);

    if ( !String.IsNullOrEmpty(replacementText) )
    pLinkToTarget.AddToCategory(replacementText);

    pLinkToTarget.Save("Global category replacement in progress.", false);
    }

    catch {

    continue;
    }

     
    • CodeDriller
      CodeDriller
      2009-06-04

      I just tested your code on MediaWiki 1.15alpha (r48811) and found no error. Everything must be working properly.

      Please, tell me:

      1) What version of DotNetWikiBot you are working with?
      2) What version of MediaWiki you are working on?
      3) Is your wiki available from the Internet, so I could test it myself?
      4) If not, are you familiar with the debugger? Could you get the contents of the "postData" variable and "respStr" variable in the Save() function, when the exception is thrown?

      One more suggestion: try setting "Bot.useBotQuery == false;" in the beginning of your program.

       
    • White Mystery
      White Mystery
      2009-06-07

      Thanks for the quick response.  Sorry for the delay in my response - the SF crash yesterday got me.

      1. I'm using 2.7 right now.  I was using 2.64, when I encountered the problem for the first time.  I updated to 2.65 to see if it fixed it, then finally updated to 2.7.  While I may be wrong, I don't recall having this problem in the past when I was using versions 2.0 and 2.21.  I wrote the bot a while ago on 2.0, did the upgrade to 2.21 and then it was idle for a while, until I upgraded to the 2.64.

      2. The bot is being used on two sites, both experiencing the problem.  The first is running 1.13.3 and the second is an internal wiki running 1.12.0.

      3. My apologies if you are remotely familiar with the site, but it is Encyclopedia Dramatica at http://www.encyclopediadramatica.com.  If you are not familiar with the site, I would recommend not visiting it at work.

      4. If for any reason you are unable to get to the site or do not want to get to the site, I can use the debugger to get this information for you.

      I tried setting the bot query flag at the beginning of the program and I encountered the same results.

      Thank you again for your help and time!

       
    • CodeDriller
      CodeDriller
      2009-07-03

      Sorry for delay.
      Please, try changing 13 to 15 on line 1099 (as of 2.7 source code). Like that:

          (site.ver.Major > 1 || (site.ver.Major == 1 && site.ver.Minor >= 15)))

      Tell me if it helps.

       
    • White Mystery
      White Mystery
      2009-07-24

      Apologies for the delayed response. I just wanted to say thank you - the fix AND the most recent release brought my maintenance bot back in to working order and everyone at the site is very grateful!

       
      • CodeDriller
        CodeDriller
        2009-07-25

        Glad to be of assistance.