Files
dimgigov cd46edcb67
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Bump version to 1.1.6; fix storage bugs, tests, CI pipeline and Docker config
Storage fixes:
- Fix bloom filter hash2 OverflowDefect (uint64 instead of int Hash)
- Fix MemTable.put size calculation on overwrite (was leaking size)
- Fix fuzz_test duplicate-key issues in LSM delete and SSTable tests

Test fixes:
- Fix stress_test.nim: replace deprecated threadpool with std/threads
- Fix fuzz_test.nim: add missing imports (tables, algorithm, sets)
- Fix fuzz_test.nim: var sst for close() compatibility
- Remove unused imports from test_all.nim and bench_all.nim

Docker / CI fixes:
- Fix Dockerfile.source: invalid nimlang/nim:2.2.10-alpine tag → 2.2.10 + ubuntu:24.04 runtime
- Fix Dockerfile.source healthcheck (--spider → -qO- for 200 OK)
- Fix Dockerfile run comment ports (9470/9471 → 9912/9913)
- Fix scripts/docker-run.sh healthcheck port (9470 → 9912)
- Add ARG BUILD_DATE/VCS_REF to Dockerfile for docker-build.sh
- Update all version strings 1.1.4 → 1.1.6 across nimble/docker/source/docs
2026-05-19 12:13:33 +03:00

5.0 KiB

Мониторинг и Наблюдаемост

Health Checks

HTTP Health Endpoint

curl http://localhost:9470/health

Отговор:

{
  "status": "healthy",
  "version": "1.1.6",
  "uptime_seconds": 86400,
  "checks": {
    "storage": "ok",
    "memory": "ok",
    "connections": "ok"
  }
}

Readiness Probe

curl http://localhost:9470/ready

Връща 200 OK когато сървърът е готов да приема трафик, 503 по време на стартиране.

Метрики

Prometheus-Съвместими Метрики

curl http://localhost:9470/metrics

Примерен изход:

# HELP baradb_queries_total Общ брой изпълнени заявки
# TYPE baradb_queries_total counter
baradb_queries_total 152340

# HELP baradb_queries_duration_seconds Хистограма на времетраене на заявки
# TYPE baradb_queries_duration_seconds histogram
baradb_queries_duration_seconds_bucket{le="0.001"} 45000
baradb_queries_duration_seconds_bucket{le="0.01"} 120000
baradb_queries_duration_seconds_bucket{le="0.1"} 148000

# HELP baradb_storage_lsm_size_bytes Общ размер на LSM-Tree
# TYPE baradb_storage_lsm_size_bytes gauge
baradb_storage_lsm_size_bytes 2147483648

# HELP baradb_cache_hit_rate Page cache hit rate
# TYPE baradb_cache_hit_rate gauge
baradb_cache_hit_rate 0.94

# HELP baradb_active_connections Активни клиентски връзки
# TYPE baradb_active_connections gauge
baradb_active_connections 42

JSON Метрики

curl http://localhost:9470/metrics?format=json

Логване

Нива на Логване

Ниво Описание
debug Детайлни вътрешни операции
info Нормални операции
warn Възстановими проблеми
error Грешки, изискващи внимание

Структурирани JSON Логове

BARADB_LOG_LEVEL=info \
BARADB_LOG_FORMAT=json \
BARADB_LOG_FILE=/var/log/baradb/baradb.log \
./build/baradadb

Примерен лог запис:

{
  "timestamp": "2025-01-15T10:30:00.123Z",
  "level": "info",
  "component": "server",
  "message": "Query executed",
  "query": "SELECT * FROM users",
  "duration_ms": 12,
  "client_ip": "10.0.0.15"
}

Текстов Формат

BARADB_LOG_FORMAT=text ./build/baradadb

Правила за Алармиране

Prometheus AlertManager

groups:
  - name: baradb
    rules:
      - alert: BaraDBHighErrorRate
        expr: rate(baradb_errors_total[5m]) > 0.1
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Висок процент грешки в BaraDB"

      - alert: BaraDBLowCacheHitRate
        expr: baradb_cache_hit_rate < 0.8
        for: 10m
        labels:
          severity: warning
        annotations:
          summary: "Cache hit rate под 80%"

      - alert: BaraDBHighConnections
        expr: baradb_active_connections > 800
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Голям брой връзки към BaraDB"

      - alert: BaraDBDown
        expr: up{job="baradb"} == 0
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "BaraDB инстанцията не работи"

Разпределен Мониторинг

Клъстерни Метрики

За Raft клъстери, мониторирайте:

curl http://node1:9470/metrics/cluster
{
  "cluster_id": "baradb-cluster-1",
  "nodes": [
    {"id": "node1", "role": "leader", "health": "healthy"},
    {"id": "node2", "role": "follower", "health": "healthy"},
    {"id": "node3", "role": "follower", "health": "healthy"}
  ],
  "raft_log_index": 15420,
  "raft_commit_index": 15420,
  "shards": 4,
  "replication_lag_ms": 5
}

Профилиране на Производителност

Вграден CPU Profiler

curl -X POST http://localhost:9470/debug/pprof/cpu?seconds=30 > cpu.prof

Memory Profiler

curl http://localhost:9470/debug/pprof/heap > heap.prof

Отстраняване на Проблеми с Метрики

Симптом Метрика Действие
Бавни заявки baradb_queries_duration_seconds Проверете cache hit rate, добавете индекси
Висока памет process_resident_memory_bytes Намалете memtable/cache размери
Растящо съхранение baradb_storage_lsm_size_bytes Пуснете ръчен compaction
Грешки при връзка baradb_active_connections Увеличете connection pool или добавете възли
Репликационно закъснение baradb_replication_lag_ms Проверете мрежата, увеличете ресурсите