Search code examples
windowperforce

Problem coming while doing p4 sync on 70 machines from same client


There is a client on windows: "client_common" having following specififcation:

Client: client_common

Update: 2023/10/20 06:12:30

Access: 2023/11/17 02:07:31

Owner:  PCS

Root:   C:\farm\test

Options:        noallwrite noclobber nocompress unlocked nomodtime normdir

SubmitOptions:  submitunchanged

LineEnd:        unix

View:
        //depot/etc/19.10/rc01/fe/PSD_PV... //client_common/test/PSD_PV...
 

When I am running p4 sync ... on 70 machines simulataneously, newly added/updated files are coming on just 1-2 machines, and not all. Why so?

And how can i make p4 sync ... to have incrementally new/updated files updated/added in all machines?


Solution

  • When I am running p4 sync ... on 70 machines simulataneously, newly added/updated files are coming on just 1-2 machines, and not all. Why so?

    There are two things working against you here:

    • The server maintains a "have list" for each client spec to optimize file transfers. When the client receives the file, the server remembers that the client has that revision, and won't send an update until there's a new revision or the client specifically requests a different revision from what it has (unless you use -f which forces the server to disregard the have list). Since you're sharing one client spec across multiple machines, when the server sends the file to one machine, it effectively assumes that all of them have it. If all the machines are sharing a single network-mounted workspace, that's probably fine, but if they each have their own workspace, the have list will not agree with the actual workspace state, and that will cause you to miss files when you sync.
    • To avoid concurrency issues when updating the client state (like the have list) in the database, the server takes a lock on the client when it's processing a command that updates that client's state -- commands are not generally parallelizable within the same client workspace. Again, because you're sharing one client spec across multiple machines, all of those commands are probably being serialized.

    And how can i make p4 sync ... to have incrementally new/updated files updated/added in all machines?

    Create a different client spec for each machine. This is the way that client specs are intended to be managed: one client spec per client machine. This is why each client spec is bound to a specific Host by default -- it's to help keep you from accidentally using a single client spec on multiple client hosts and encountering the exact problem that you encountered.

    Note that when creating lots of client specs, you can use the -t option to use one client as a template for another. Go to each machine and do:

    p4 set P4CLIENT=a_unique_client_name_for_this_client_host
    p4 client -t client_common -o | p4 client -i
    

    and now you have a unique client with the same view as client_common (but very importantly its own physical workspace and its own have list).

    If you're willing to have the sync operation fetch all the files every time rather than the incrementally updated ones, you can share a client spec, but in that case you should use the p4 sync -p command on all the machines.

    The -p flag is specifically for build machines that often want to fetch all the files, do a build, and then immediately clean up the workspace -- since there's no point in maintaining a have list in that scenario, -p syncs the files without updating the have list, which makes it a little faster and a little more predictable for the build client use case, at the cost of making it completely unsuitable for incremental syncs of the type that an end user will usually want to do.