MongoDB Troubleshooting¶
This guide provides steps to diagnose and resolve common issues related to MongoDB when used with Hyperion. Remember, MongoDB is conditionally required by Hyperion; it's only used if you enable state tracking features (features.tables.* or features.contract_state.enabled) in your chain configuration file.
For installation details, refer to the Manual Installation Guide.
Basic Service Management (systemd)¶
Ensure the MongoDB service (mongod) is running correctly on the host machine where it's installed.
-
Check Status:
Look forsudo systemctl status mongodactive (running). -
Start Service:
sudo systemctl start mongod -
Stop Service:
sudo systemctl stop mongod -
Enable on Boot: (Recommended)
sudo systemctl enable mongod -
View Logs:
- Systemd Journal:
sudo journalctl -u mongod -f - MongoDB Log File (Default):
sudo tail -f /var/log/mongodb/mongod.log
- Systemd Journal:
Connection Issues¶
If Hyperion (API or Indexer) cannot connect to MongoDB:
- Verify Service is Running: Use
sudo systemctl status mongodon the MongoDB host. - Check
config/connections.json: Ensure themongodbsection has the correcthost,port,user,pass, anddatabase_prefix."mongodb": { "host": "127.0.0.1", // Or the correct IP/hostname "port": 27017, "database_prefix": "hyperion", // Ensure this matches expectations "user": "hyperion_user", // Or blank if no auth "pass": "your_password" // Or blank if no auth } - Test Connectivity with
hyp-config: Run this from your Hyperion installation directory. It specifically tests the configuration inconnections.json.Look for the MongoDB test result../hyp-config connections test - Manual Connection Test (
mongosh): From the Hyperion machine, try connecting directly using the MongoDB Shell.- Without Authentication:
mongosh --host <mongodb_host> --port <mongodb_port> # Example: mongosh --host 192.168.1.100 --port 27017 - With Authentication:
If the manual connection fails:
mongosh --host <mongodb_host> --port <mongodb_port> --username <user> --password <password> --authenticationDatabase <auth_db> # Example: mongosh --host 192.168.1.100 --port 27017 -u hyperion_user -p your_password --authenticationDatabase admin - Check
bindIp: On the MongoDB host, check the/etc/mongod.conffile. Ensure thenet.bindIpsetting includes the IP address of your Hyperion machine or0.0.0.0(less secure). Restartmongodafter changes. - Check Firewalls: Ensure firewalls on both the MongoDB host and the Hyperion machine allow traffic on the MongoDB port (default
27017).
- Without Authentication:
Authentication Errors¶
If Hyperion logs show authentication failures:
- Verify Credentials: Double-check the
userandpassinconfig/connections.jsonagainst the actual user credentials configured within MongoDB. - Check User Existence & Permissions: Use
mongoshas an admin user on the MongoDB server to verify the Hyperion user exists and has the necessary roles (likereadWrite) on the target Hyperion databases (e.g.,hyperion_wax,hyperion_eos). Refer to MongoDB's documentation on managing users and roles.
Missing Data or Collections¶
If /v2/state/ endpoints return empty results or errors about missing collections (e.g., accounts, voters, <contract>-<table>):
- Check Feature Flags: Ensure the corresponding features are enabled in
config/chains/<chain>.config.json:features.tables.accounts: true(for token balances/holders)features.tables.voters: true(for voters)features.tables.proposals: true(for proposals)features.contract_state.enabled: true(for specific contract tables)- Ensure the specific contracts/tables are defined under
features.contract_state.contractsif using that feature.
- Check Database/Collections Exist: Use
mongoshon the MongoDB server:mongosh --host ... # Connect first show dbs # Look for your hyperion_<chain> database use hyperion_<chain> show collections # Check if expected collections (accounts, voters, proposals, <contract>-<table>) exist - Data Not Yet Indexed/Synchronized: If the features were enabled after the indexer processed the relevant historical blocks, the state data might be missing. You need to manually synchronize:
- Requirement: The Hyperion Indexer for the target chain must be running and its control port (configured in
connections.json, default 7002) must be accessible from where you run the command. - Commands (run from Hyperion root dir):
# Sync specific contract state tables defined in config ./hyp-control sync contract-state <chain-name> # Sync system state tables (if enabled in config) ./hyp-control sync accounts <chain-name> ./hyp-control sync voters <chain-name> ./hyp-control sync proposals <chain-name> # Or sync everything configured ./hyp-control sync all <chain-name> - This process can take time depending on the amount of data. Monitor indexer logs (
pm2 logs <chain>-indexer).
- Requirement: The Hyperion Indexer for the target chain must be running and its control port (configured in
Performance Issues (Slow Queries/Indexing)¶
If /v2/state/ queries are slow or the indexer seems bottlenecked during state updates:
- Monitor Host Resources: Check RAM, CPU, and especially Disk I/O usage on the MongoDB host using tools like
htop,iostat,vmstat. High I/O wait often indicates storage bottlenecks. - Check MongoDB Logs: Look for slow query logs in
/var/log/mongodb/mongod.log. You might need to configure the profiling level inmongod.confto capture these. - Verify Indexes: Proper indexes are crucial for query performance.
- Use
mongoshto check existing indexes:use hyperion_<chain> db.accounts.getIndexes() # Check indexes for 'accounts' collection db.voters.getIndexes() # Check indexes for 'voters' collection db.<contract>-<table>.getIndexes() # Check indexes for a contract state table - Ensure indexes exist for fields commonly used in your queries (especially for
get_table_rowsfilters). - Use
./hyp-config contracts ...to manage indexes forcontract_statetables (including settingautoIndex: true). - The
hyp-control synctools generally create necessary indexes for the system tables (accounts,voters,proposals).
- Use
- Hardware Resources: Slow performance might simply indicate insufficient RAM, CPU, or slow disk speed for the workload, especially if indexing large contract state tables.
Disk Space Issues¶
- Check Disk Usage: Use
df -hon the MongoDB host to check available disk space. - Check Data Directory Size: Find the MongoDB data directory path in
/etc/mongod.conf(usually/var/lib/mongodb) and check its size:sudo du -sh /var/lib/mongodb. - Resolution: If disk space is low, you may need to add more storage, prune unnecessary data (if applicable, less common for state DBs than time-series ES data), or investigate specific collections that are consuming excessive space.
General Tips¶
- Always check the Hyperion Indexer logs (
pm2 logs <chain>-indexer) for specific errors related to MongoDB operations (bulk writes, etc.). - Consult the official MongoDB Documentation for detailed information on configuration, performance tuning, and troubleshooting.