Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Too many pending asynchronous disk write causes spurious errors

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee Gillie - 11 Aug 2005 17:19 GMT
I am using the asynchronous I/O model to receive data over a socket, and
asynchronously write the incoming data to a disk file using FileStream.
So long as the pending writes have not yet completed I continue to
allocate more read buffers. As a result I can get a backlog of about 250
disk writes (1K buffers, because that is the max size the receiver will
give me).

During the course of a 50 MB transfer I get about 6 of these errors:

07:42:50.14 System.IndexOutOfRangeException: Probable I/O race condition
detected while copying memory.  The I/O package is not thread safe by
default.  In multithreaded applications, a stream must be accessed in a
thread-safe way, such as a thread-safe wrapper returned by TextReader's
or TextWriter's Synchronized methods.  This also applies to classes like
StreamWriter and StreamReader.

07:42:50.14    at System.Buffer.InternalBlockCopy(Array src, Int32
srcOffset, Array dst, Int32 dstOffset, Int32 count)

07:42:50.14    at System.IO.FileStream.BeginWrite(Byte[] array, Int32
offset, Int32 numBytes, AsyncCallback userCallback, Object stateObject)

07:42:50.14    at
ODP.NMServe.DataChannelSession.ReceiveHandler(IAsyncResult ar)

I am obviously doing SOMETHING wrong. I was thinking the
FileSystem.BeginWrite was supposed to be safe to work from in the thread
pool utilized by the socket read completions. And that there was safe
FIFO queueing of requests. The FileStream was opened with the
asynchronous option TRUE. I am not sure what the error messages are
looking for, what I need to change to avoid this.

The disk I am writing to is an SCSI RAID 5 disk array. This runs on a
dual processor W2K box.

Thanks for any pointers

Best regards - Lee Gillie
Lee Gillie - 11 Aug 2005 18:18 GMT
Nevermind.

I see I was misusing my buffer arbiter. I find I have a backlock of
about 80-90 1K buffers when writing to the disk, and those should not
return to the buffer pool until the write has completed for the buffer.
I was returning it after having queued the write (incorrectly).

- Lee

> I am using the asynchronous I/O model to receive data over a socket, and
> asynchronously write the incoming data to a disk file using FileStream.
[quoted text clipped - 34 lines]
>
> Best regards - Lee Gillie

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.