[p4] Delete orphaned shelved files from master server

Michael Mirman perforce-user-forum at forums.perforce.com
Wed Apr 8 18:30:01 PDT 2015

Posted on behalf of forum user 'Michael Mirman'.

We have this and some similar issues with shelves in the distributed
We are currently using 2014.2 Patch5 (I think) - going to Patch6 this weekend.
Most problems are about shelves made in 2014.1 and prior.

Here are a few ideas that might help you:

1. Client cannot indeed be unloaded from an edge server if it has shelves.
However, the client can be deleted with -df -Fs, disconnecting itself from the
shelves (well, -Fs became available in a certain version - see if you have it).
Then, you can recreate the client with the same name on the commit server, and
it will immediately see the shelves.
Note that if shelves are truly promoted (run p4 -ztag describe -s NNNN and see
is IsPromoted is set), the client on an edge server should see the shelf.
This means that if you promote the shelf (p4 shelve -p -c NNNN) before you
unload the client on the comit server, then the shelf is *usually* accessible
from the edge server where you will reload the client.

2. You can change the client of an empty change as long as the client is on the
same server where the change was originated.
This is a very neat trick.
Say, I have a shelf in a client on an edge server, and this shelf
"looks" empty. I don;t know why it looks empty, but it does. (We had
~1,400 shelves like that a few months ago before I started the
"recover" process.)

In case if the pending change is empty (no open files), here's the sequence
of operations I would do to recover:

- create a temporary client on the same edge server where the change is now (the
View is the same as the original client);
- change the client of the damaged change to the temporary client;
- delete the temporary client with -df -Fs, leaving the shelf
At this point, the shelf belongs to a the client, which does not exist anymore.
- recreate the temporary client on the commit server. Now the shelf is
accessible. Fix it while you can - maybe unshelve, and reshelve with -p;
Now go back:
- delete the temp client with -df -Fs;
- recreate nit on the edge server;
- change the client of the change to the original client.

I scripted it, but having so many different edge cases does not make the script
good for a general use.
I got the number of damaged shelves to ~400 and can't figure out why they
would appear empty regardless of where the client is.
The archive files are there, but the change doesn't see the files.
My next step is to actually find the archive files, recover the files content,
add them to the change and reshelve.


Please click here to see the post in its original format:

More information about the perforce-user mailing list