Working over unreliable networks
To set a hard upper bound on how long a connection is willing to wait on
any single network read or write, set the net.maxwait configurable to the number of seconds to wait before disconnecting with a
network error. Users working over unreliable connections can set
net.maxwait
value either in their P4CONFIG files, or use -vnet.maxwait=
on a
per-command basis, where t
t
is the number of seconds
to wait before timing out.
Although net.maxwait
can be set on the
Helix Core server, it is
generally inadvisable to do so. For example, if
net.maxwait
is set to 60
on the server, users
of the Command-Line Client must complete every interactive form within
one minute before the command times out. If, however, individual users
set net.maxwait
in their own P4CONFIG
files
(which reside on their own workstations) their connections are not
subject to this limitation; commands only fail if the versioning
service takes more than 60 seconds to respond to their requests.
It is useful to combine net.maxwait
with the
-rN
global option, where N
is the number
of times to attempt reconnection in the event that the network times out.
For example:
$ p4 -r3 -vnet.maxwait=60 sync
attempts to sync the user’s workspace, making up to three attempts to resume the sync if interrupted. The command fails after the third 60-second timeout.
Because the format of the output of a command that times out and is
restarted cannot be guaranteed (for example, if network connectivity is
broken in the middle of a line of output), avoid the use of
-r
on any command that reads from standard input. For
example, the behavior of the following command, which reads a list of
files from stdin and passes it to p4 add, can result
in the attempted addition of "half a filename" to the depot.
$ find . -print | p4 -x - -r3 add
To prevent this from happening (for example, if adding a large number of files over a very unreliable connection), consider an approach like the following:
$ find directoryname -type f -exec p4 -r5 -vmax.netwait=60 add {} \;
All files (-type f
) in directoryname
are found, and added one at a time, by invoking the command "p4
-r5 -vmax.netwait=60 add
" for each file individually.
After all files have been added, assign the changelist a changelist number with p4 change, and submit the numbered atomically with:
$ p4 -r5 -vmax.netwait=60 submit -c changenum
If connectivity is interrupted, the numbered changelist submission is resumed.