Skip to content

[codex] Prevent concurrent AP and TP modes - #670

Draft
zhanglei1949 wants to merge 1 commit into
alibaba:mainfrom
zhanglei1949:codex/ap-tp-mode-validation
Draft

[codex] Prevent concurrent AP and TP modes#670
zhanglei1949 wants to merge 1 commit into
alibaba:mainfrom
zhanglei1949:codex/ap-tp-mode-validation

Conversation

@zhanglei1949

Copy link
Copy Markdown
Member

Summary

Fixes #663.

  • Add a NeugDB mode state so embedded AP connections and TP service/session mode cannot be active at the same time.
  • Track AP connection lifetime through close callbacks, and release TP mode when NeugDBService is destroyed.
  • Stop NeugDBService from silently closing embedded connections on construction; it now rejects active AP connections instead.
  • Lock Python connect() / serve() entry points and add Python/C++ coverage for the AP/TP exclusion.

Root Cause

AP embedded Connection and TP NeugDBService could previously be active on the same NeugDB instance. That allowed AP flows such as checkpoint/close cleanup to run while TP WAL/session state still referenced the old checkpoint/WAL directory, creating a data-loss hazard.

Tests

  • /opt/homebrew/bin/cmake --build build --target test_db_svc transaction_test -j8
  • env MODERN_GRAPH_DATA_DIR=/Users/zhanglei/code/cloud-cli/neug/example_dataset/modern_graph build/tests/unittest/test_db_svc --gtest_filter='NeugDBServiceTest.*'
  • build/tests/transaction/transaction_test --gtest_filter='WalReplay*:CompactTransactionTest.*'
  • PATH=/opt/homebrew/bin:$PATH PYTHON=/opt/homebrew/opt/python@3.13/bin/python3.13 JOBS=8 make dev from tools/python_bind
  • /opt/homebrew/opt/python@3.13/bin/python3.13 -m pytest -s tests/test_tp_service.py -k 'serve_rejects_active_embedded_connection or connect_rejected_while_service_active'
  • /opt/homebrew/bin/cmake --build build --target test_connection -j8
  • env MODERN_GRAPH_DATA_DIR=/Users/zhanglei/code/cloud-cli/neug/example_dataset/modern_graph build/tests/unittest/test_connection
  • git diff --check

@zhanglei1949
zhanglei1949 force-pushed the codex/ap-tp-mode-validation branch from c991658 to c698233 Compare July 1, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AP/TP mode switching lacks entry-point validation: prevent concurrent embedded connection and TP service

1 participant