What is Atom?
Directory Ops Behaving Asynchronous
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > .Net Development > Directory Ops Behaving Asynchronous 5 August 2009 15:28:46

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

Directory Ops Behaving Asynchronous

Brady Kelly 19 May 2008 21:42:33
 I have the following code execute:



if (Directory.Exists(e­xportFolder))

{

Directory.Delete(ex­portFolder, true);

}

Directory.CreateDir­ectory(exportFolder)­;



and then a database update, and then:



wiz57.PerformExport­();



Occassionally, about 1 in 20 tests I run in the IDE, PerformExport fails
because exportFolder does not exist. How can it not exist if I create it and
no exception is thrown? I can only suspect that the Directory code is not
truly synchronous, and has not completed before PerformExport executes.



Brady Kelly
Software Developer

Chase Software
Office: 011 287 1820
Cell: 078 331 3781
Fax: 086 691 5653

<http://www.chaseso­ftware.co.za/> www.ChaseSoftware.c­o.za




===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Ryan Heath 19 May 2008 23:54:56 permanent link ]
 I cannot speak for Dir.Del but another thing to consider: Are there
other threads/progs deleting/creating that dir?

// Ryan

2008/5/19, Brady Kelly <brady@chasesoftwar­e.co.za>:
I have the following code execute:
if (Directory.Exists(e­xportFolder))
{
Directory.Delete(ex­portFolder, true);
}
Directory.CreateDir­ectory(exportFolder)­;
and then a database update, and then:
wiz57.PerformExport­();
Occassionally, about 1 in 20 tests I run in the IDE, PerformExport fails
because exportFolder does not exist. How can it not exist if I create it and
no exception is thrown? I can only suspect that the Directory code is not
truly synchronous, and has not completed before PerformExport executes.
Brady Kelly
Software Developer
Chase Software
Office: 011 287 1820
Cell: 078 331 3781
Fax: 086 691 5653
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Ryan Rinaldi 19 May 2008 23:56:35 permanent link ]
 What test framework are you using?

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Brady
Kelly
Sent: Monday, May 19, 2008 12:43 PM
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: [DOTNET-CLR] Directory Ops Behaving Asynchronous

I have the following code execute:



if (Directory.Exists(e­xportFolder))

{

Directory.Delete(ex­portFolder, true);

}

Directory.CreateDir­ectory(exportFolder)­;



and then a database update, and then:



wiz57.PerformExport­();



Occassionally, about 1 in 20 tests I run in the IDE, PerformExport fails
because exportFolder does not exist. How can it not exist if I create it
and
no exception is thrown? I can only suspect that the Directory code is
not
truly synchronous, and has not completed before PerformExport executes.



Brady Kelly
Software Developer

Chase Software
Office: 011 287 1820
Cell: 078 331 3781
Fax: 086 691 5653

<http://www.chaseso­ftware.co.za/> www.ChaseSoftware.c­o.za




===================­================
This list is hosted by DevelopMentor(r) http://www.develop.­com

View archives and manage your subscription(s) at
http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 20 May 2008 12:28:28 permanent link ]
 
I cannot speak for Dir.Del but another thing to consider: Are there
other threads/progs deleting/creating that dir?
// Ryan

No.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 20 May 2008 12:29:06 permanent link ]
 None, I'm just running a test C# console application.

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Ryan
Rinaldi (TT)
Sent: 19 May 2008 09:57 PM
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: Re: [DOTNET-CLR] Directory Ops Behaving Asynchronous
What test framework are you using?
-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Brady
Kelly
Sent: Monday, May 19, 2008 12:43 PM
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: [DOTNET-CLR] Directory Ops Behaving Asynchronous
I have the following code execute:
if (Directory.Exists(e­xportFolder))
{
Directory.Delete(ex­portFolder, true);
}
Directory.CreateDir­ectory(exportFolder)­;
and then a database update, and then:
wiz57.PerformExport­();
Occassionally, about 1 in 20 tests I run in the IDE, PerformExport
fails
because exportFolder does not exist. How can it not exist if I create
it
and
no exception is thrown? I can only suspect that the Directory code is
not
truly synchronous, and has not completed before PerformExport executes.
Brady Kelly
Software Developer
Chase Software
Office: 011 287 1820
Cell: 078 331 3781
Fax: 086 691 5653
===================­================
This list is hosted by DevelopMentor(r) http://www.develop.­com
View archives and manage your subscription(s) at
===================­================
This list is hosted by DevelopMentor. http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Greg Young 20 May 2008 19:24:40 permanent link ]
 I am unable to duplicate your issue ... Are you using a local or a
network drive? Can you provide your test application so I can look
through it?

Cheers,

Greg

On Tue, May 20, 2008 at 1:29 AM, Brady Kelly <brady@chasesoftwar­e.co.za> wrote:
None, I'm just running a test C# console application.
-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Ryan
Rinaldi (TT)
Sent: 19 May 2008 09:57 PM
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: Re: [DOTNET-CLR] Directory Ops Behaving Asynchronous
What test framework are you using?
-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Brady
Kelly
Sent: Monday, May 19, 2008 12:43 PM
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: [DOTNET-CLR] Directory Ops Behaving Asynchronous
I have the following code execute:
if (Directory.Exists(e­xportFolder))
{
Directory.Delete(ex­portFolder, true);
}
Directory.CreateDir­ectory(exportFolder)­;
and then a database update, and then:
wiz57.PerformExport­();
Occassionally, about 1 in 20 tests I run in the IDE, PerformExport
fails
because exportFolder does not exist. How can it not exist if I create
it
and
no exception is thrown? I can only suspect that the Directory code is
not
truly synchronous, and has not completed before PerformExport executes.
Brady Kelly
Software Developer
Chase Software
Office: 011 287 1820
Cell: 078 331 3781
Fax: 086 691 5653
===================­================
This list is hosted by DevelopMentor(r) http://www.develop.­com
View archives and manage your subscription(s) at
===================­================
This list is hosted by DevelopMentor. http://www.develop.­com
View archives and manage your subscription(s) at
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com



--
We are what we repeatedly do. Excellence, then, is a habit.

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 20 May 2008 20:00:54 permanent link ]
 
I am unable to duplicate your issue ... Are you using a local or a
network drive? Can you provide your test application so I can look
through it?
Cheers,
Greg

It's a local drive, and I'm also unable to duplicate the issue _at will_.
The test application is rather convoluted, as it's been something of a
scripting, rather than development exercise, but I'll try and trim it down.
Thanks.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Peter Ritchie 20 May 2008 20:27:13 permanent link ]
 I'm unable to reproduce too ,in 10,000 iterations performing the actions
you've described (except the database update). Can you provide the
details of the exception?

Do you have an anti-virus programming running? What happens if you turn
it off?

If there truly is no other threads or processes that are deleting that
directory, I can't think of anything else that could cause that.

Is the directory a sub-directory of a shared directory? I once
encountered someone with mysterious disappearing files because he had
shared the directory and a user on another computer was performing
housekeeping on what they thought was a local drive. But, about 1 in 20
seems a little too regular for that...

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 20 May 2008 20:54:08 permanent link ]
 Peter Richie:

I'm unable to reproduce too ,in 10,000 iterations performing the
actions
you've described (except the database update). Can you provide the
details of the exception?

I'll do some iterations myself and check the frequency. My initial 1 in 20
was very ballpark, I was running each test individually, not in an iterative
set.

Do you have an anti-virus programming running? What happens if you
turn
it off?

I do have it running, and will check what happens when I turn it off.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Fabian Schmied 23 May 2008 20:11:49 permanent link ]
 I'm seeing the same problem every once in a while when running a high
number of automated tests (NUnit 2.2 or 2.4 in this case) with each
test deleting and re-creating a directory: sometimes, directory
creation fails immediately after the original was deleted. The IO
exception claims that the old directory still exists. Everything is
strictly sequential, no multithreading going on. The directory is a
perfectly ordinary NTFS folder on a local hard drive (with RAID
mirroring). And it happens on different PCs, so it's likely not a
hardware issue.

It's not reproducible at all, so it's hard to find the cause of the
issue (file system, virus scanner, .NET, ...). In fact, we decided to
just work around this issue by running a short while-Directory.Exi­sts
loop after the delete operation, spinning until the directory is
really gone. This "solves" the issue for our test suite, although a
deeper explanation would be nice, of course.

Fabian


On 5/20/08, Peter Ritchie
<dotnetclr.discuss.­develop.com@peterrit­chie.com> wrote:
I'm unable to reproduce too ,in 10,000 iterations performing the actions
you've described (except the database update). Can you provide the
details of the exception?
Do you have an anti-virus programming running? What happens if you turn
it off?
If there truly is no other threads or processes that are deleting that
directory, I can't think of anything else that could cause that.
Is the directory a sub-directory of a shared directory? I once
encountered someone with mysterious disappearing files because he had
shared the directory and a user on another computer was performing
housekeeping on what they thought was a local drive. But, about 1 in 20
seems a little too regular for that...
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Ryan Rinaldi 23 May 2008 20:41:53 permanent link ]
 Could it be some sort of race condition with write-behind caching?

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Fabian
Schmied
Sent: Friday, May 23, 2008 11:12 AM
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: Re: [DOTNET-CLR] Directory Ops Behaving Asynchronous

I'm seeing the same problem every once in a while when running a high
number of automated tests (NUnit 2.2 or 2.4 in this case) with each
test deleting and re-creating a directory: sometimes, directory
creation fails immediately after the original was deleted. The IO
exception claims that the old directory still exists. Everything is
strictly sequential, no multithreading going on. The directory is a
perfectly ordinary NTFS folder on a local hard drive (with RAID
mirroring). And it happens on different PCs, so it's likely not a
hardware issue.

It's not reproducible at all, so it's hard to find the cause of the
issue (file system, virus scanner, .NET, ...). In fact, we decided to
just work around this issue by running a short while-Directory.Exi­sts
loop after the delete operation, spinning until the directory is
really gone. This "solves" the issue for our test suite, although a
deeper explanation would be nice, of course.

Fabian


On 5/20/08, Peter Ritchie
<dotnetclr.discuss.­develop.com@peterrit­chie.com> wrote:
I'm unable to reproduce too ,in 10,000 iterations performing the
actions
you've described (except the database update). Can you provide the
details of the exception?
Do you have an anti-virus programming running? What happens if you
turn
it off?
If there truly is no other threads or processes that are deleting that
directory, I can't think of anything else that could cause that.
Is the directory a sub-directory of a shared directory? I once
encountered someone with mysterious disappearing files because he had
shared the directory and a user on another computer was performing
housekeeping on what they thought was a local drive. But, about 1 in
20
seems a little too regular for that...
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at
http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor(r) http://www.develop.­com

View archives and manage your subscription(s) at
http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Sebastien Lambla 23 May 2008 21:05:26 permanent link ]
 I've had issues with some of my build scripts. While running procmon, I've
seen the case where the folder appears deleted, but when a try on creating
the folder, it gets an access denied with a DELETE PENDING status.

It may or may not be related, just thought I'd suggest to run procmon and
see where you get an access denied. .net doesn't report some of them as
accurately as one may expect.

Seb

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:D­OTNET-CLR@DISCUSS.DEVELOP.COM] On Behalf Of Fabian Schmied
Sent: 23 May 2008 17:12
To: DOTNET-CLR@DISCUSS.­DEVELOP.COM
Subject: Re: [DOTNET-CLR] Directory Ops Behaving Asynchronous

I'm seeing the same problem every once in a while when running a high
number of automated tests (NUnit 2.2 or 2.4 in this case) with each
test deleting and re-creating a directory: sometimes, directory
creation fails immediately after the original was deleted. The IO
exception claims that the old directory still exists. Everything is
strictly sequential, no multithreading going on. The directory is a
perfectly ordinary NTFS folder on a local hard drive (with RAID
mirroring). And it happens on different PCs, so it's likely not a
hardware issue.

It's not reproducible at all, so it's hard to find the cause of the
issue (file system, virus scanner, .NET, ...). In fact, we decided to
just work around this issue by running a short while-Directory.Exi­sts
loop after the delete operation, spinning until the directory is
really gone. This "solves" the issue for our test suite, although a
deeper explanation would be nice, of course.

Fabian


On 5/20/08, Peter Ritchie
<dotnetclr.discuss.­develop.com@peterrit­chie.com> wrote:
I'm unable to reproduce too ,in 10,000 iterations performing the actions
you've described (except the database update). Can you provide the
details of the exception?
Do you have an anti-virus programming running? What happens if you turn
it off?
If there truly is no other threads or processes that are deleting that
directory, I can't think of anything else that could cause that.
Is the directory a sub-directory of a shared directory? I once
encountered someone with mysterious disappearing files because he had
shared the directory and a user on another computer was performing
housekeeping on what they thought was a local drive. But, about 1 in 20
seems a little too regular for that...
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at
http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentorR http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Peter Ritchie 23 May 2008 22:06:43 permanent link ]
 The "delete pending" error occurs if you delete a file or folder but
there's still an active handle for that file or folder somewhere. I'm not
clear whether that only occurs if the handle is in another application
(like virus scanners) or in the same application (the one deleting the
file/folder).

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 5 June 2008 15:52:37 permanent link ]
 Follow up: This only seems to happen when the directory is created just
before calling a COM component that uses the directory. It has happened
twice now on two tests. The first time I re-ran the test without error,
before moving on to the next test instance, where I got the error again.
Unfortunately this round of testing is about a hundred fold bigger than the
last, and single test tasks run to tens of minutes.

2008/5/19, Brady Kelly <brady@chasesoftwar­e.co.za>:
I have the following code execute:
if (Directory.Exists(e­xportFolder))
{
Directory.Delete(ex­portFolder, true);
}
Directory.CreateDir­ectory(exportFolder)­;
and then a database update, and then:
wiz57.PerformExport­();
Occassionally, about 1 in 20 tests I run in the IDE, PerformExport
fails
because exportFolder does not exist. How can it not exist if I create
it and
no exception is thrown? I can only suspect that the Directory code is
not
truly synchronous, and has not completed before PerformExport
executes.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Davy J 7 June 2008 19:22:08 permanent link ]
 Brad,
I hit this a few years ago , if I remember correctly there was no
solution, the only way was to itterate through the files collection
and delete them individually.

hth

Davy J


On Mon, May 19, 2008 at 7:42 PM, Brady Kelly <brady@chasesoftwar­e.co.za> wrote:
I have the following code execute:
if (Directory.Exists(e­xportFolder))
{
Directory.Delete(ex­portFolder, true);
}
Directory.CreateDir­ectory(exportFolder)­;
and then a database update, and then:
wiz57.PerformExport­();
Occassionally, about 1 in 20 tests I run in the IDE, PerformExport fails
because exportFolder does not exist. How can it not exist if I create it and
no exception is thrown? I can only suspect that the Directory code is not
truly synchronous, and has not completed before PerformExport executes.
Brady Kelly
Software Developer

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Guest 3 May 2009 02:50:00 permanent link ]
 I had the same problem.
C# ASP.net 3.5 still has this bug.
About if you do Directory.Delete and then Remake the Directory about 1 time in 20 it fails on large tests
Add comment
Guest 5 August 2009 15:28:46 permanent link ]
 I have seen this behavior too, using .NET 2.0 runtime. In a unit test, I create a directory, then delete it via Directory.Delete(di­rectory, true) in some business logic, and then in the unit test assert that Directory.Exists(di­rectory) returns false. Sometimes it returns true instead, even though clearly the directory was deleted, as evidenced by examining it after the test completes. Thanks for making Directory.Delete(x,­ true) asynchronous, Microsoft! Not!
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > .Net Development > Directory Ops Behaving Asynchronous 5 August 2009 15:28:46

see also:
[JBoss Seam] - Seam + ScopeType.EVENT
[Beginners Corner] - session ejb socket…
[JBoss/Spring Integration] - Re…
pass tests:
Do you really know yourself?
see also:
How to copy a DVD(on Mac)and burn a…
How to Download/Play/Convert YouTube…
Recommended: Converters for Sony…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .