Troubleshooting

Troubleshooting

Solutions to common problems, error codes, and performance optimization guide for Machbase.

Common Issues

Server Issues

Server Won’t Start

Symptoms:

  • machadmin -u fails
  • “Address already in use” error
  • No server process running

Solutions:

# Check if port is in use
netstat -an | grep 5656
lsof -i :5656

# Kill existing process
kill $(lsof -t -i:5656)

# Check database directory
ls -la $MACHBASE_HOME/dbs/

# Review logs
tail -50 $MACHBASE_HOME/trc/machbase.log

# Try starting again
machadmin -u

Server Crashes

Symptoms:

  • Server stops unexpectedly
  • Core dump files
  • “Segmentation fault” errors

Solutions:

# Check logs
tail -100 $MACHBASE_HOME/trc/machbase.log

# Check system resources
free -h
df -h

# Reduce memory usage (in machbase.conf)
BUFFER_POOL_SIZE = 1G

# Check for disk space
du -sh $MACHBASE_HOME/dbs/

Connection Issues

Cannot Connect

Symptoms:

  • “Connection refused” error
  • “Connection timeout”
  • machsql fails to connect

Solutions:

# Verify server is running
machadmin -e

# Check network connectivity
ping server-address
telnet server-address 5656

# Check firewall
sudo iptables -L | grep 5656

# Verify credentials
machsql -s localhost -u SYS -p MANAGER

Too Many Connections

Symptoms:

  • “Max connections exceeded” error
  • New connections rejected

Solutions:

-- Check active connections
SHOW STATEMENTS;

-- Increase MAX_CONNECTION in machbase.conf
-- MAX_CONNECTION = 200

-- Kill idle connections (if necessary)

Query Issues

Slow Queries

Symptoms:

  • Queries take too long
  • Timeout errors
  • High CPU usage

Solutions:

-- Add time filter
SELECT * FROM table DURATION 1 HOUR;  -- Add this!

-- Use LIMIT
SELECT * FROM table LIMIT 1000;

-- Query rollup instead of raw data
SELECT * FROM sensors WHERE rollup = hour;

-- Create index
CREATE INDEX idx_column ON table(column);

-- Check query plan
EXPLAIN SELECT ...;

Out of Memory

Symptoms:

  • “Out of memory” error
  • Query fails midway
  • Server becomes unresponsive

Solutions:

-- Reduce result set
SELECT * FROM table DURATION 1 HOUR LIMIT 1000;

-- Select fewer columns
SELECT col1, col2 FROM table;  -- Not SELECT *

-- Increase MAX_QPX_MEM in machbase.conf
-- MAX_QPX_MEM = 1G

Data Issues

Import Fails

Symptoms:

  • machloader error
  • CSV import fails
  • Data type mismatch

Solutions:

# Check CSV format
head -10 data.csv

# Verify table schema
machsql -f - <<EOF
SHOW TABLE tablename;
EOF

# Check error log
cat $MACHBASE_HOME/trc/machloader.log

# Validate data types
# Ensure CSV columns match table schema

# Try small batch first
head -100 data.csv > test.csv
machloader -t table -d csv -i test.csv

Missing Data

Symptoms:

  • Expected data not found
  • Count mismatch
  • Time gaps

Solutions:

-- Check time range
SELECT MIN(_arrival_time), MAX(_arrival_time) FROM table;

-- Check total count
SELECT COUNT(*) FROM table;

-- Check for NULLs
SELECT COUNT(*) FROM table WHERE column IS NULL;

-- Verify import completed
-- Check machloader logs

Error Codes

Common Error Messages

Error CodeMessageSolution
-20000Connection failedCheck server status, network
-20001Authentication failedVerify username/password
-20100Table not foundCheck table name, use SHOW TABLES
-20101Column not foundVerify column name, use SHOW TABLE
-20200Duplicate keyCheck PRIMARY KEY constraints
-20300Data type mismatchValidate data types
-30000Out of memoryReduce query size, increase memory
-30100TimeoutAdd time filter, increase timeout

For complete error code reference, see Error Codes.

Performance Optimization

Query Optimization

  1. Always use time filters
-- Bad
SELECT * FROM sensors WHERE sensor_id = 'sensor01';

-- Good
SELECT * FROM sensors
WHERE sensor_id = 'sensor01'
DURATION 1 HOUR;
  1. Use rollup for analytics
-- Slow
SELECT AVG(value) FROM sensors DURATION 7 DAY;

-- Fast
SELECT AVG(avg_value) FROM sensors
WHERE rollup = hour
DURATION 7 DAY;
  1. Create indexes
CREATE INDEX idx_level ON logs(level);
  1. Limit results
SELECT * FROM logs DURATION 1 DAY LIMIT 1000;

Server Tuning

# Memory optimization
BUFFER_POOL_SIZE = 4G       # 50-70% of RAM
MAX_QPX_MEM = 1G            # Per-query memory
LOG_BUFFER_SIZE = 128M      # Write buffer

# Performance tuning
CHECKPOINT_INTERVAL_SEC = 900
MAX_PARALLEL_QUERY = 8

Data Management

  1. Implement retention
DELETE FROM logs EXCEPT 30 DAYS;
  1. Batch writes
# Use APPEND API for bulk inserts
appender = conn.create_appender('table')
for row in data:
    appender.append(row)
appender.close()
  1. Monitor storage
SHOW STORAGE;

Diagnostic Commands

Check Server Status

# Server running?
machadmin -e

# View active queries
machsql -f - <<EOF
SHOW STATEMENTS;
EOF

# Check storage
machsql -f - <<EOF
SHOW STORAGE;
EOF

Check Logs

# Server log
tail -50 $MACHBASE_HOME/trc/machbase.log

# Error log
grep -i error $MACHBASE_HOME/trc/machbase.log

# Recent activity
tail -100 $MACHBASE_HOME/trc/machbase.log

System Information

-- Tables
SHOW TABLES;

-- Table details
SHOW TABLE tablename;

-- Users
SHOW USERS;

-- Indexes
SHOW INDEXES;

-- License
SHOW LICENSE;

Getting Help

Information to Gather

When reporting issues, collect:

  1. Error message (exact text)
  2. Server logs ($MACHBASE_HOME/trc/machbase.log)
  3. Machbase version (machadmin -v)
  4. Operating system (uname -a)
  5. Steps to reproduce

Support Resources

Best Practices to Avoid Issues

  1. Always use time filters in queries
  2. Implement data retention policies
  3. Monitor server resources regularly
  4. Regular backups (daily)
  5. Test queries on small datasets first
  6. Use appropriate table types for data
  7. Keep Machbase updated to latest version

Quick Fixes

# Restart server
machadmin -s && sleep 5 && machadmin -u

# Check disk space
df -h

# Check memory
free -h

# View recent errors
grep -i error $MACHBASE_HOME/trc/machbase.log | tail -20

# Test connection
machsql -s localhost -u SYS -p MANAGER -f - <<EOF
SELECT SYSDATE;
EOF

Related Documentation

Last updated on