Why can't I rename a folder?
-
@Yamikuronue said in Why can't I rename a folder?:
That horse is so far out of the barn he's at the glue factory >.>
@Yamikuronue said in Why can't I rename a folder?:
What the powershell script is doing is renaming components to old, then unpacking components.tar.gz which unpacks to components.
The question is whether the folder's locked or a file inside it. If a file inside it is locked, then you also can't touch the folder (as @flabdablet said). In that case, yes, you'll need to figure out what is holding the lock (try
handle
) and figure out how to stop it.If the folder itself is locked, but none of the files inside it are, then moving them all from
components
toold
should succeed. Then unpackingcomponents.tar.gz
intocomponents
should also succeed....actually, what happens to
old
? Your problem might just be that it already exists when you try to renamecomponents
->old
...
-
@anotherusername said in Why can't I rename a folder?:
, what happens to old?
It's deleted.
@anotherusername said in Why can't I rename a folder?:
Your problem might just be that it already exists
Is that a thing that can give this error?
-
Are you Folder's legal guardian? Does hi want his name changes? Why do you want to change his name?
-
@fbmac It's step one in his murder.
-
@Yamikuronue okay, no, then the error message would be different. Also the error message for a file lock on the folder would also be different. But the error message for a lock on a file within that folder... yes:
However, if you make the destination folder and then try to move the contents, then you actually do get the error that indicates a locked file:
And it tells which file is locked.
Overall, I think your best bet is to use
handle
to figure out which process is locking it, and figure out how to stop that process so that it unlocks the file.
-
Assuming it is in fact a locking issue: Sysinternals Process Explorer is the canonical way to debug those. If it points back to system holding a file open, that means it's being hit via a share, and theres some other relevant management tool for that.
-
@Yamikuronue said in The Yamirant Thread:
Some of you might have noted that I have an extremely exhasperated-sounding thread in the general help section about Windows servers. Our order queue is on one of the affected servers. The issue is sporadic. We may need to get Microsoft involved, because we're all totally stumped.
Has anyone actually tried either using Process Explorer or Handle?
Someone could add even Handle into the script so that when it failed to rename the folder, it spat out the details of what's got it locked.
-
@Weng said in Why can't I rename a folder?:
Process Explorer
@loopback0 said in Why can't I rename a folder?:
Process Explorer
Yes, we're doing that now.... we can't get it to fail.
Might be we're not always waiting long enough after IIS stops.
-
@Yamikuronue IIS Service stop or site/app stop?
-
@Weng Service
-
@Yamikuronue Yeah, we have a whole category of transient deploy issues where we stop a service and immediately hit file locks that should be gone. I think Windows reports stoppage when it receives the return from the service OnStop API, but before it's finished cleaning up the remains of the carcass process.
We solved them by doing all the shutdowns at the top of the deployment in the order the components will be deployed, so by the time the last service stops, enough time has elapsed that the first will definitely be good to deploy.
A timed delay would be equivalent.
-
@Weng said in Why can't I rename a folder?:
I think Windows reports stoppage when it receives the return from the service OnStop API, but before it's finished cleaning up the remains of the carcass process.
I believe that's the case; OnStop has to return within a certain timeframe in order for the SCM to report success.
-
Not that simply delaying is ideal, but there really isn't anything to watch for unless you explicitly check handles on all the files you're going to touch, which is pretty overwraught.
-
@RaceProUK Yeah. Which is great fun because the service then goes on to stop anyway (assuming it's not actually hung)
-
@Weng
I thinkhandle c:\folder\name
would work. If there's a file inside it open, it should still match on the folder name and show a result.Stop IIS, check
handle
every x seconds until 0 rows returned.
-
EUREKA!
After an hour and a half of trying to repro, we got it to fail while we were looking at it
-
@Weng said in Why can't I rename a folder?:
A timed delay would be equivalent.
We have a 10s delay after every tgime we run Stop-Service for this very issue
-
Maybe it was Symantec? We're looking at every event from every process within about a second of the failure either way and finding nothing running but powershell and Windows.... and Symantec.
-
-
It wasn't symantec
-
Latest theory: we fixed the issue weeks ago and this server has a different issue, a known bug where sometimes the service manager gets out of sync with the services and we have a 'ghost service' running that says it's stopped.
-
@Yamikuronue said in Why can't I rename a folder?:
Maybe it was Symantec? We're looking at every event from every process within about a second of the failure either way and finding nothing running but powershell and Windows.... and Symantec.
Alter the script so that it spits out the output of
handle c:\folder\path
immediately before and/or after renaming it?
-
A developer had a session open on the machine with an xml file open.
two goddamn hours I spent debugging that.
two goddamn hours.
two.
goddamn.
hours.TWO GODDAMN HOURS.
I quit IT forever.
-
@Yamikuronue The phrase you're looking for is 'justifiable homicide'
-
@Yamikuronue said in Why can't I rename a folder?:
A developer had a session open on the machine with an xml file open.
Too bad I didn't see this earlier. I would have told you that NET FILE will show locks from other computers.
-
@Yamikuronue been there done that, except it was a production issue.
-
-
@Jaime said in Why can't I rename a folder?:
from other computers.
It wasn't. We went to try a reboot and it said "There's another user logged in, do you want to kill his session" and so instead we looked at his session and he had iexplore.exe open.
-
@Yamikuronue said in Why can't I rename a folder?:
We're looking at every event from every process within about a second of the failure either way and finding nothing running but powershell and Windows
Every event... wait, were you using Process Explorer
or Process Monitor?
Only the latter knows about events, but it's way clumsier to use for tracking down open handles than Process Explorer, which would have led you straight to the process holding the handle and from there to the user ID of that process's owner.
-
@Yamikuronue said in Why can't I rename a folder?:
There's another user logged in, do you want to kill his session
I'll need you to go ahead and do that, and if you could go ahead and kill him as well... that would be great.
-
@Yamikuronue said in Why can't I rename a folder?:
A developer had a session open on the machine with an xml file open.
... why can a dev even HAVE a msts sessopn OPEN on a build server?!
BAD DEV! BAD! I'MMA DRIVE OVER THERE AND GIVE YOU SUCH A SMACK! NO SOUP FOR YOU! EVER!
-
@flabdablet The latter, but I wasn't driving. I don't have that kind of access to these machines. I was hitting the build button over and over while the sysadmin worked on the machine.
-
@accalia said in Why can't I rename a folder?:
on a build server?!
No, no, on the web server. To verify that the file got there correctly when he didn't trust the build server's result. Which is fair, since it was a failure, but it apparently got there anyway.
-
@Yamikuronue So you have an incompetent sysadmin. Because that should have taken 10 minutes at most.
It's okay, we have the same problem (but I've gradually gotten myself access and do everything that doesn't need access to the Vsphere console myself).
-
@Weng No comment (at least, in this thread)
-
@Yamikuronue said in Why can't I rename a folder?:
Yes, we're doing that now.... we can't get it to fail.
Good news, everyone! She fixed the problem! Or at least found a mitigation.
-
@Yamikuronue said in Why can't I rename a folder?:
To verify that the file got there correctly when he didn't trust the build server's result.
Why would you not use something like curl/wget + fciv?!
"Ignorance of at least two of those utilities" is about the only acceptable answer.
-
@FrostCat said in Why can't I rename a folder?:
Why would you not use something like curl/wget + fciv?!
This is a company which took 11 days to figure out what was locking a file/folder on a server.
-
@accalia said in Why can't I rename a folder?:
... why can a dev even HAVE a msts sessopn OPEN on a build server?!
I do this on occasion on my work PC. It's like having virtual desktops natively! Almost. And it requires certain flags to allow multiple sessions on the same user. And a compatible version of Windows. And a.... Well, it's nice sometimes.
Oh, you said
build server
... Sorry, ignorethis
and continue...
-
@loopback0 To be fair, on 7 of the servers involved, it was a sporadic issue. We didn't notice the 8th was doing it every time until we decided to try switching which server we were hammering.