Skip to content

Operations

@nx/search không có deployment độc lập. Nó chạy bên trong container host (commerce) và chia sẻ vòng đời, replica, và resource của host. Vận hành nó nghĩa là vận hành Typesense, Debezium connector, và CDC consumer chạy trong commerce.

1. Deployment

Thuộc tínhGiá trị
ImageN/A — đóng gói vào image commerce
ReplicasN/A — bằng replica commerce
ResourcesThêm memory Kafka consumer + Typesense client vào host
ProbesProbe host; TypesenseHelper.getHealth() gate collection sync + circuit breaker
Migration modeSchema-drift check khi boot (không auto-apply); script backfill thủ công cho thay đổi
Snowflake ID rangeN/A

Dependency phải reachable

DependencyCần choNếu down
Typesensesearch + indexingBootstrap skip collection sync (log warn); circuit breaker pause CDC
Kafka + DebeziumCDC syncIndex ngừng cập nhật; consumer reconnect; offset không commit

Không có Traefik labels — route mount dưới base path của host service (/v1/api/commerce/...).

2. Observability

SignalNguồnNơi xem
LogsHost stdout (key-value có cấu trúc)log pod commerce — lọc scope component (ApplicationCdcComponent, TypesenseSearchEngineComponent)
CDC startupdòng log Starting CDC consumer | Brokers… | DLQ… | CircuitBreaker…xác nhận topic + state breaker
Schema synclog Schema divergence detected | Collection: …báo cần migration thủ công
Indexing throughputmetric batch SearchIndexingServicetrường log theo từng batch
HealthTypesenseHelper.getHealth()breaker probe + bootstrap gate

Chẩn đoán Sync

Thao tácLệnh
Check số dòng Typesense ↔ nguồnscripts/check_sync_status.sh
Dry-run backfill referencebun run migrate:references:dry
Dry-run backfill denormbun run migrate:denorm:dry

3. Security

Mối quan tâmBiện pháp
AuthNRoute search kế thừa host JWT/Basic (AuthenticateStrategy.JWT, .BASIC)
AuthZsearch:search / search:search-count; mixin yêu cầu config authorize của consumer
Tenant isolationresolveSearchScope() and-merge một scope where vào mọi query
Typesense API keyAPP_ENV_TYPESENSE_API_KEY từ secret host; không bao giờ trong code
Kafka SASLAPP_ENV_KAFKA_SASL_* khi broker yêu cầu auth
Không client writeDocument chỉ mutate qua CDC — không có public write API

4. Runbook

4.1 Lớp Alert

AlertTriggerCheckFixEscalate
searchSchemaDivergencelog Schema divergence detected khi bootSo sánh config vs schema Typesense liveChạy script backfill cho thay đổi additive; recreate collection chỉ khi an toàn về data-lossbackend on-call
searchCdcLagCDC consumer tụt lại / circuit OPENTypesense health, lag consumer-group KafkaPhục hồi Typesense; breaker close sau quiet windowSRE on-call
searchDlqGrowthmessage tích lũy trong nx.seller.cdc.dlqInspect payload DLQ + metadata lỗiFix mapper/data, replay từ DLQbackend on-call
searchStalekết quả thiếu dòng vừa thay đổiscripts/check_sync_status.shBackfill hoặc replay topic bị ảnh hưởngbackend on-call

4.2 Thao tác thường gặp

Thao tácLệnh / Action
Tail log CDCkubectl logs -f deploy/commerce | grep -E 'Cdc|Typesense'
Verify số syncbun run check_sync_status (hoặc scripts/check_sync_status.sh)
Backfill references / denormbun run migrate:references / bun run migrate:denorm
Reindex sau khi đổi schemaRecreate collection đã phân kỳ (cửa sổ an toàn về data-loss) rồi backfill
Replay một CDC topicReset offset Debezium connector / consumer-group (do infra sở hữu)

5. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.