Two processes writing to the same XML file at the same time?

Discussion in 'ASP .Net' started by darrel, Mar 29, 2006.

  1. darrel

    darrel Guest

    Our production web site went down today. We discovered that it was because
    the XML file we use to create the site navigation (most all of the controls
    on every page rely on this XML file) was only half-written.

    We're not sure why.

    One theory is that two people happened to modify the database at the exact
    same time thereby triggering the application to write the XML file at the
    exact same time and somehow 'colliding'. But even that doesn't seem to make
    sense to us...why would it cause the file to only be half-written.

    Is there anything else we should consider poking at or peeking into that
    might have caused an XML file to only be half written?

    -Darrel
     
    darrel, Mar 29, 2006
    #1
    1. Advertising

  2. I once had a similar problem with an Access database table. That problem
    was caused by using a SQL command to delete the contents of the table
    followed immediately by code to repopulate the table. Apparently the
    repopulation was starting before the delete was completed causing a
    corruption of the data in the table with the records that should have been
    first appearing further down in the table.

    However, I have no idea if this applies to your situation.

    Additionally, I believe you can lock (for writing by anyone else until you
    close the file) the xml file you are writing to by using the
    IO.FileShare.Read property in the sample code below

    Dim fs As New System.IO.FileStream("YourXmlFile.xml", IO.FileMode.Open,
    IO.FileAccess.Write, IO.FileShare.Read)
    Dim xmltw As New System.Xml.XmlTextWriter(fs, System.Text.Encoding.Default)
    xmltw.WriteString("Your xml text")


    "darrel" <> wrote in message
    news:...
    > Our production web site went down today. We discovered that it was because
    > the XML file we use to create the site navigation (most all of the
    > controls on every page rely on this XML file) was only half-written.
    >
    > We're not sure why.
    >
    > One theory is that two people happened to modify the database at the exact
    > same time thereby triggering the application to write the XML file at the
    > exact same time and somehow 'colliding'. But even that doesn't seem to
    > make sense to us...why would it cause the file to only be half-written.
    >
    > Is there anything else we should consider poking at or peeking into that
    > might have caused an XML file to only be half written?
    >
    > -Darrel
    >
    >
     
    William LaMartin, Mar 30, 2006
    #2
    1. Advertising

  3. darrel

    darrel Guest

    William:

    Sorry for not getting back to you on this. THANKS for the info!

    -Darrel

    > Additionally, I believe you can lock (for writing by anyone else until you
    > close the file) the xml file you are writing to by using the
    > IO.FileShare.Read property in the sample code below
    >
    > Dim fs As New System.IO.FileStream("YourXmlFile.xml", IO.FileMode.Open,
    > IO.FileAccess.Write, IO.FileShare.Read)
    > Dim xmltw As New System.Xml.XmlTextWriter(fs,
    > System.Text.Encoding.Default)
    > xmltw.WriteString("Your xml text")
     
    darrel, Apr 5, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gabor
    Replies:
    19
    Views:
    1,133
    Steve Holden
    May 31, 2005
  2. Jp Calderone
    Replies:
    7
    Views:
    1,193
    Mike Meyer
    May 28, 2005
  3. Jp Calderone
    Replies:
    0
    Views:
    463
    Jp Calderone
    May 27, 2005
  4. Jp Calderone
    Replies:
    4
    Views:
    453
    gabor
    May 31, 2005
  5. id10t error
    Replies:
    3
    Views:
    733
    Alexey Smirnov
    Aug 31, 2009
Loading...

Share This Page