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

D

darrel

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
 
W

William LaMartin

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")
 
D

darrel

William:

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

-Darrel
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top