Skip to main content
This guide covers essential maintenance operations for keeping your Graph Node infrastructure running efficiently using graphman.

Prerequisites

The graphman command is included in official Graph Node containers. You can access it via:
Ensure you have a configuration file set up. See the basic setup guide if you need to create one.

Logging Configuration

Graphman respects the GRAPH_LOG environment variable. To reduce log noise:

Verify Setup

Confirm graphman is configured correctly:
This should display basic deployment information, including the Postgres namespace.

Removing Unused Deployments

When you deploy a new version of a subgraph, the previous version’s data remains in the database even after it’s no longer served for queries. These unused deployments consume storage and should be periodically cleaned up.

Understanding Unused Deployments

A deployment is considered unused when it meets all of these criteria:
  1. Not assigned to any node
  2. Either not marked as active, or is neither the current nor pending version of a subgraph
  3. Not the source of a currently running copy operation

Cleanup Process

1

Record unused deployments

Scan all shards and identify unused deployments:
This compiles a list and stores it in the unused_deployments table in the primary shard.
No data is deleted at this stage. This command only identifies and marks deployments for removal.
2

Review the list

Inspect which deployments are marked for removal:
Verify that the listed deployments should indeed be removed.
3

Remove unused deployments

Delete the data for marked deployments:
This operation is irreversible. All indexed data for these deployments will be permanently deleted.
Deployments are removed in descending order by entity count (smaller deployments first).

Removal Options

The unused remove command supports several options for fine-grained control:
Removes all deployments previously marked with unused record.
Only removes deployments recorded at least 720 minutes (12 hours) ago. This provides a safety buffer.
Targets a single deployment by its IPFS hash.
Removes only the specified number of deployments, useful for gradual cleanup.

Removing a Subgraph

To stop serving a specific subgraph and free its name for reuse:
1

Remove the subgraph name mapping

This removes the association between the subgraph name and its deployment.
2

Mark the deployment as unused

If no other subgraph name uses this deployment:
3

Remove the deployment data

After confirming it’s safe to delete:
Removing a subgraph name does not immediately delete indexed data. The deployment becomes eligible for cleanup through the unused deployment process.

Modifying Assignments

Each deployment is assigned to a specific Graph Node instance for indexing. You can modify these assignments to control which node indexes which subgraphs.

Reassigning Deployments

Move a deployment to a different node:
Arguments:
  • <deployment> - The deployment identifier (name, IPFS hash, or namespace)
  • <new-node-id> - The target node ID from your Graph Node configuration
This is useful for:
  • Load balancing across multiple nodes
  • Moving deployments off a node before maintenance
  • Isolating problematic subgraphs

Unassigning Deployments

Permanently stop indexing a deployment:
The deployment remains in the database but stops receiving updates.
To resume indexing, reassign the deployment to an active node. No data is lost during unassignment.

Pausing Indexing

To temporarily pause a deployment without losing its assignment:
To resume:
Currently, graphman does not support creating assignments for completely unassigned deployments. You can only reassign or pause existing assignments.

Complete Deployment Removal

To fully remove a deployment in a single operation:
This command combines multiple operations:
1

Retrieve deployment info

Identifies the deployment and its associated data
2

Unassign from node

Stops indexing activity
3

Remove subgraph name

Frees the name for reuse
4

Mark as unused

Registers the deployment for deletion
5

Delete all data

Permanently removes indexed data
The drop command is irreversible. Use with caution and consider backing up critical data first.

Drop Command Options

Use in automation scripts only.

Maintenance Workflows

Regular Cleanup Schedule

Establish a routine maintenance schedule:
1

Weekly: Identify unused deployments

2

Weekly: Review and remove

Wait 24-48 hours, then:
This ensures deployments have been truly unused for at least a day.
3

Monthly: Audit active deployments

Review all deployments to identify candidates for archival:

Pre-Deployment Cleanup

Before deploying a new version:
1

Check current deployment info

Note the current deployment hash and version.
2

Deploy new version

Deploy your updated subgraph using the Graph CLI or your deployment tool.
3

Wait for sync completion

Monitor the new deployment until it’s fully synced.
4

Clean up old version

Wait at least 1 hour to ensure the old version is no longer needed.

Node Maintenance

When performing maintenance on a Graph Node instance:
1

List deployments on the node

Identify which deployments are assigned to the node.
2

Reassign critical deployments

Move important subgraphs to other nodes.
3

Pause remaining deployments

4

Perform maintenance

Update, restart, or repair the node.
5

Restore assignments

Return deployments to the maintained node.

Best Practices

Always use graphman info and unused list to confirm which deployments will be affected before running destructive operations.
Wait at least 1 hour (preferably 24 hours) between marking deployments as unused and removing them using the --older flag.
Track database size trends to determine optimal cleanup frequency. Unused deployments can consume significant storage.
Maintain a record of which deployments are assigned to which nodes, especially in multi-node setups.
If possible, test maintenance operations in a staging environment before running them in production.
Create scripts for regular maintenance tasks, but always include safety checks and confirmation steps.
Before removing old deployments, consider exporting critical data or keeping deployment metadata for audit purposes.

Troubleshooting Common Issues

Deployment won’t unassign

Symptom: Unassign command fails or deployment continues indexing. Solutions:
  • Verify the deployment identifier is correct
  • Check that no queries are actively using the deployment
  • Ensure the node is not restarting or in an error state

Unused remove doesn’t delete deployment

Symptom: Deployment remains in database after unused remove. Causes and solutions:
  • Not marked as unused: Run graphman unused record first
  • Still assigned: Unassign the deployment before marking as unused
  • Recent deployment: Use --older 0 to remove immediately (not recommended)
  • Active queries: Wait for queries to complete

Can’t reassign deployment

Symptom: Reassign command fails or assignment doesn’t change. Solutions:
  • Verify the target node ID exists in your configuration
  • Check that the target node is running and connected to the database
  • Ensure the deployment isn’t in a failed state
  • Try unassigning first, then creating a new assignment

Database space not freed after removal

Symptom: Disk usage remains high after removing deployments. Solutions:
  • Run PostgreSQL’s VACUUM FULL on affected schemas (requires downtime)
  • Consider using VACUUM regularly to mark space as reusable
  • Check for other large tables or indexes
  • Monitor the primary shard’s unused_deployments table size

Automation Examples

Daily Cleanup Script

Deployment Migration Script

Additional Resources