Use the read-only replica

You can perform all normal operations against your master server (p4 -p master:1666 command). To reduce the load on the master server, direct reporting (read-only) commands to the replica (p4 -p replica:1667 command). Because the replica is running in -M readonly -D readonly mode, commands that read both metadata and depot file contents are available, and reporting commands (such as p4 annotate, p4 changes, p4 filelog, p4 diff2, p4 jobs, and others) work normally. However, commands that update the server’s metadata or depot files are blocked.

The steps on this page assume you have logged into the master server as the Helix Core user with the access level of super. See Permission levels and access rights in the p4 protect topic of Helix Core Command-Line (P4) Reference. That user can have any name, but for convenience the examples use super:

p4 -u super login

Commands that update metadata

Some scenarios are relatively straightforward: consider a command such as p4 sync. A plain p4 sync fails, because whenever you sync your workspace, the Helix Core Server must update its metadata (the "have" list, which is stored in the db.have table). Instead, use p4 sync -p to populate a workspace without updating the have list:

p4 -u super -p replica:1667 sync -p //depot/project/...@1234

This operation succeeds because it does not update the server’s metadata.

Some commands affect metadata in more subtle ways. For example, many Helix Core Server commands update the last-update time that is associated with a specification (for example, a user or client specification). Attempting to use such commands on replica servers produces errors unless you use the -o option. For example, p4 client (which updates the Update: and Access fields of the client specification) fails:

p4 -u super -p replica:1667 client replica_client
Replica does not support this command.

However, p4 client -o works:

p4 -u super -p replica:1667 client -o replica_client

and the client spec is output to STDOUT.

If a command is blocked due to an implicit attempt to write to the server’s metadata, consider the options described above, as well as the broker. (Some commands, like p4 submit, always fail, because they attempt to write to the replica server’s depot files. These commands are blocked by the -D readonly option.)