p4 topology
Reports the P4 servers that are connected directly and indirectly to the innermost server, including an indicator of the server this command is running on.
Syntax
p4 [g-opts] topology [-a | -t numOfDays] [-F filter] [-T field,...] p4 [g-opts] topology -D date [-l 0] [-y] [-e] [-a] [-s serverAddress [-i serverID] [-p targetAddress]] p4 [g-opts] topology -D -l lastSeenDate [-y] [-e] [-a] [-s serverAddress [-i serverID] [-p targetAddress]] p4 [g-opts] topology -d [-y] -s serverAddress -i serverID [-p targetAddress] p4 [g-opts] topology -d [-y] -c date [-e] p4 [g-opts] topology -d [-y] -l lastSeenDate [-e] p4 topology -m [-y] -s serverAddress -i serverID -S newServerAddress -I newServerID p4 topology -m [-y] -s serverAddress -i serverID -p targetAddress -S newServerAddress -I newServerID -P newTargetAddress p4 topology --retention-purge[=interval] [--tombstone-retain=secs] [-y]
Description
This command:
-
Reports the P4 servers that are connected directly and indirectly to the innermost server.
-
Includes an indicator of the server this command is running on, such as
Topology command was run on server - 127.0.0.1:1677 -
Relies on the Topology table of the database schema.
These servers can be connected directly or indirectly. The types of servers listed are: standard, commit, edge (including edge-to-edge chaining), read-only replica, forwarding replica, standby, build, proxy, and broker.
By default, the command reports only the latest configurations based on the P4 Server address, Target server address, and serverID for each service.
Output format
|
Command |
Format of the output |
|---|---|
p4 topology
|
untagged, used by the Perforce admin for a quick validation |
p4 -ztag topology
|
tagged (see -z tag under Global options) |
p4 -ztag -Mj topology
|
JSON (see -Mj tag under Global options) |
Options
| Option | Description |
|---|---|
|
|
(Optional) Display all the configurations of the services that are captured in the Topology table. With the See Example of -a to see all records as well as db.topology in P4 Schema Documentation. With |
-d
|
Defaults to a preview of marking a record as deleted, which:
If there are multiple entries with the same server address, destination address, and server id, the operation is performed on the server record with the latest timestamp of its creation. To execute the operation, include the |
-D
|
Defaults to a preview of the permanent deletion of the record based on the date in Linux epoch
format. This date does not necessarily correspond to a Used on its own, Combine To
permanently delete the specified records from the table, include the |
-c creationDate
|
Specify the creation date in Linux epoch format. The creationDate represents the first time the server record was entered into the Topology table. |
-l lastSeenDate
|
Specify the last seen date in Linux epoch format. The lastSeenDate represents the last time the server record was updated. Combined with |
-e
|
Include all the
records earlier than, and including, the specified date, whichever date field is matched (creationDate or lastSeenDate). |
-y
|
Can be used with -d, -D, -m, and --retention-purge to perform the action rather than show a preview. |
-s serverAddress
|
The server address. |
-p
|
The existing target address. |
-i
|
The existing server ID as opposed to -I, the new server ID when using the -m option. |
-S
|
The new server address when using the -m option. |
-P
|
The new target address. |
-I
|
The new server ID. |
-m
|
Ensures that the move operation marks the specified source server record as being moved to the target server. If the topology record has the target address,
it is mandatory to provide both the source target address Defaults to a preview. To execute the operation, include the |
-t numberOfDays
|
Display the configurations recorded during the specified number of The |
-F filter
|
List only those records that match the criteria specified by
The filter pattern can be a regular expression. Topology uses the same filtering as p4 fstat. See Filter with -F on the |
-T field
|
Limits output to the specified fields, where the specified fields are in a comma-separated list. See Limit fields with -T . |
--retention-purge[=interval]
|
Permanently purges aged delete and move tombstone records from the Topology table. Only records older than the age set by Without an interval,
|
--tombstone-retain=secs
|
Specify, in seconds, the age that a delete or move tombstone record must reach before Defaults to off: if |
|
|
See
Global options, especially |
Usage notes
| Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
|---|---|---|
|
N/A |
N/A |
available to an operator user |
Output that includes 0.0.0.0 indicates that the host address is unspecified. In such a case, P4 Server listens on all the available IPV4 addresses on the host. For example, if a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a P4 Server running on this host listens on 0.0.0.0, the server is listening on both IP addresses.
Behavior notes
Of the topology subcommands, only --retention-purge is allowed to run as a startup.N configurable. If any other topology subcommand is configured under startup.N, the server rejects it with a usage error.
A record with a lastSeenDate of 0 falls back to matching by creationDate. This is normal for records that were written before an upgrade to a server version that records lastSeenDate.
Setting or changing a startup.N configurable, including one that runs topology --retention-purge, requires a server restart before it takes effect.
Consider --retention-purge on the commit server only. Tombstone records that it purges are removed from edge servers as those servers catch up through replication.
When a pass finds nothing to purge, whether in preview mode, with -y, or because --tombstone-retain is absent, 0, or negative, --retention-purge prints nothing. If a pass encounters an error, it prints only the error, not a count.
When N is greater than 0, --retention-purge prints one of the following messages:
Preview, without -y:
Preview: --retention-purge would remove N topology record(s). Rerun with -y to actually purge.
Purge, with -y:
Topology retention purge removed N topology record(s).
Examples
Limit time with -t
p4 topology -t 7 outputs results for the current day as well as six days prior to the current day.
Filter for fields with -F
p4 topology -F "^ServerAddress=127.0.0.1* ^ServerAddress=0.0.0.0*" uses a regular expression that filters out any results where the ServerAddress begins with 127.0.0.1 or 0.0.0.0
Limit fields with -T
If p4 -ztag topology outputs
... ServerAddress 127.0.0.1:10868
... Date 1645786193
... ServerID oldstandard
... Type standard
... LastSeenDate 1645788650
... ReportingServer true
p4 topology -T ReportingServer,ServerID limits output to the specified fields:
... ServerID oldstandard
... ReportingServer true
Delete records of a date
First, run p4 -ztag topology to get output that includes the Linux epoch date of each record, such as
... Date 1633567679
Second, preview the permanent deletion of the records with that date:
p4 topology -D 1633567679
and note that the output includes this comment:
# This is in preview mode. For actual deletion, use '-y'.
Finally, confirm that you want to permanently delete all the records of the specified date:
p4 topology -y -D 1633567679
Delete a record of a date
To delete a specific record of that date, include the server address:
p4 topology -y -D 1633567679 -s 127.0.0.1:26385
Example of deleting records prior to and including a specified date
Delete prior records
To delete records prior to and including a specified date, include the -e option
p4 topology -y -e -D 1633567679
Mark records as deleted based on creation date
p4 topology -d -c 1664451396 -y
Mark records as deleted records based on lastSeenDate
p4 topology -d -l 1664451395 -y
Example of -a to see all records
The output of p4 topology -a can be a superset of the output of p4 topology because the -a option includes records that have been superseded. In this example, a server restart is associated with the conversion of that server's type from standard to commit-server. With the -a option, records that are marked for deletion are included.
| p4 topology -a | p4 topology |
|---|---|
| 127.0.0.1:4444 standard 2022/05/18 13:59:55 commit-server 2022/05/18 13:59:55 | 127.0.0.1:4444 standard 2022/05/18 13:59:55 commit-server 2022/05/18 13:59:55 |
| 127.0.0.1:4444 standard 2022/05/18 13:59:53 standard 2022/05/18 13:59:53 | (This entry does not appear without -a because it is superseded by the server type conversion.)
|
Delete stale records by last-seen date
First, run p4 -ztag topology to find the Linux epoch value of the LastSeenDate field for the records to delete, such as
... LastSeenDate 1633567679
Second, preview the permanent deletion of every record with that last-seen date:
p4 topology -D -l 1633567679
To also delete every recorded generation of a matching server, not only the one with the latest date, add -a:
p4 topology -D -l 1633567679 -a
Finally, confirm the permanent deletion by adding -y:
p4 topology -y -D -l 1633567679 -a
Example of a one-pass retention purge
To make a single pass that purges tombstone records older than the specified retention age, in seconds, and prints the result:
p4 topology --retention-purge --tombstone-retain=2592000 -y
In this example, 2592000 seconds is 30 days. The numeric values here are placeholders for illustration, not recommended settings.
Example of a recurring retention purge with startup.N
To configure a recurring retention purge that runs as a startup.N task, repeating every interval seconds:
p4 configure set "master#startup.2=topology --retention-purge=3600 --tombstone-retain=2592000 -y"
On the server with server ID master, this command configures a startup.2 task that starts when the server starts and continues to run every 3600 seconds (1 hour).
The task runs topology --retention-purge and permanently removes topology delete and move tombstone records older than 2592000 seconds (30 days). The -y option causes the purge to be performed rather than previewed.
The interval and retention values shown here are placeholders for illustration, not recommended settings. Setting this configurable requires a server restart before the recurring purge starts running.