forked from lei.chen/myxce
Non-blocking election initiator that returns immediately after registering vote endpoints with iomgr and scheduling the election timeout watchdog. - Single-node shortcircuit (n_peers==1): allocates self-only ha_elect_ctx_t, calls ha_elect_evaluate_and_signal directly, frees ctx inline — no iomgr or delaymgr involvement; returns in < 1ms - Multi-node: allocates ha_elect_ctx_t, per-peer vote_ep_ctx_t, calls endpoint_connect + iomgr_monitor for each peer; schedules election timeout via delay_task_ms; skips peer on connect failure (counted as denied) - election_timeout_fn: delaymgr callback that fires ha_elect_evaluate_and_signal after election_timeout_ms, unless cancelled flag is set (lock-free cancellation) - vote_ep_err_handler: counts unreachable peers as denied votes - Declares ha_start_election_async in ha.h with full doc comment - 5 Unity tests in test_ha_start_election_async.c: returns < 5ms, stores n_peers, shortcircuit fires immediately, n_peers stored for multi-peer, term incremented — all GREEN with ASAN enabled
149 lines
3.7 KiB
Meson
149 lines
3.7 KiB
Meson
controller_src = [
|
|
'cluster.c',
|
|
'config_repl.c',
|
|
'dataex.c',
|
|
'ha.c',
|
|
'job.c',
|
|
'join.c',
|
|
'main.c',
|
|
'misc.c',
|
|
'myapp.c',
|
|
'opget.c',
|
|
'opupd.c',
|
|
'queue.c',
|
|
'reply.c',
|
|
'resources.c',
|
|
'sched.c',
|
|
'startup_validation.c',
|
|
'task.c',
|
|
'worker.c',
|
|
'apiserver.c',
|
|
'myconf.c',
|
|
'persist.c',
|
|
'repl.c',
|
|
'ctrl_metrics.c',
|
|
]
|
|
|
|
incdir = include_directories('.', '../include', '../lib',
|
|
'include')
|
|
|
|
# cc = meson.get_compiler('c')
|
|
# math_dep = cc.find_library('m', required : false)
|
|
|
|
zlib_dep = dependency('zlib')
|
|
|
|
controller_deps = [
|
|
libxce_dep,
|
|
librtti_dep,
|
|
c_capnproto_dep,
|
|
math_dep,
|
|
tinylog_dep,
|
|
thread_dep,
|
|
zlib_dep,
|
|
]
|
|
|
|
controller = executable('xce_controller',
|
|
controller_src,
|
|
include_directories: incdir,
|
|
dependencies: controller_deps,
|
|
link_args: wrap_link_args,
|
|
install: true)
|
|
|
|
xce_test_src = [ 'testsuite/test.c']
|
|
|
|
readline_dep = dependency('readline')
|
|
ncurses_dep = dependency('ncurses')
|
|
history_dep = dependency('history')
|
|
|
|
xce_test_deps = [
|
|
libxce_dep,
|
|
librtti_dep,
|
|
struct2json_dep,
|
|
readline_dep,
|
|
history_dep,
|
|
ncurses_dep,
|
|
tinylog_dep,
|
|
]
|
|
xce_test = executable('xce_test',
|
|
xce_test_src,
|
|
include_directories: [incdir],
|
|
dependencies: xce_test_deps,
|
|
install: true)
|
|
|
|
# Controller Unity test suite (persist types and future controller unit tests)
|
|
controller_unit_test_src = [
|
|
'testsuite/controller_test.c',
|
|
'testsuite/test_persist_types.c',
|
|
'testsuite/test_persist_wal.c',
|
|
'testsuite/test_persist_schema.c',
|
|
'testsuite/test_persist_checkpoint.c',
|
|
'testsuite/test_persist_recovery.c',
|
|
'testsuite/test_hooks.c',
|
|
'testsuite/test_persist_hooks.c',
|
|
'testsuite/test_gc_retention.c',
|
|
'testsuite/test_cluster_persist.c',
|
|
'testsuite/test_e2e_wal.c',
|
|
'testsuite/test_e2e_checkpoint.c',
|
|
'testsuite/test_e2e_hooks.c',
|
|
'testsuite/test_e2e_gc.c',
|
|
'testsuite/test_e2e_capnp.c',
|
|
'testsuite/test_ha_role.c',
|
|
'testsuite/test_ha_cluster.c',
|
|
'testsuite/test_ha_redirect.c',
|
|
'testsuite/test_p1_integration.c',
|
|
'testsuite/test_repl_unit.c',
|
|
'testsuite/test_repl_apply.c',
|
|
'testsuite/test_persist_repl.c',
|
|
'testsuite/test_repl_catchup.c',
|
|
'testsuite/test_p2_integration.c',
|
|
'testsuite/test_p3_hardening.c',
|
|
'testsuite/test_p3_manual_failover.c',
|
|
'testsuite/test_ctrl_metrics.c',
|
|
'testsuite/test_config_repl.c',
|
|
'testsuite/test_worker_join.c',
|
|
'testsuite/test_ha_startup.c',
|
|
'testsuite/test_ha_election.c',
|
|
'testsuite/test_ha_bootstrap.c',
|
|
'testsuite/test_ha_bootstrap_support.c',
|
|
'testsuite/test_ha_durability.c',
|
|
'testsuite/test_repl_majority.c',
|
|
'testsuite/test_persist_truncate.c',
|
|
'testsuite/test_ha_connect.c',
|
|
'testsuite/test_ha_ctrlhello.c',
|
|
'testsuite/test_ha_failover.c',
|
|
'testsuite/test_ha_vote_send.c',
|
|
'testsuite/test_ha_start_election_async.c',
|
|
'startup_validation.c',
|
|
'worker.c',
|
|
'persist.c',
|
|
'ha.c',
|
|
'repl.c',
|
|
'ctrl_metrics.c',
|
|
'config_repl.c',
|
|
]
|
|
|
|
ssl_dep = dependency('openssl')
|
|
|
|
controller_unit_test_deps = [
|
|
libxce_dep,
|
|
librtti_dep,
|
|
unity_dep,
|
|
tinylog_dep,
|
|
thread_dep,
|
|
zlib_dep,
|
|
c_capnproto_dep,
|
|
ssl_dep,
|
|
]
|
|
|
|
controller_unit_test = executable('controller_unit_test',
|
|
controller_unit_test_src,
|
|
include_directories: [incdir],
|
|
dependencies: controller_unit_test_deps,
|
|
c_args: ['-DXCE_TESTING'],
|
|
install: false)
|
|
|
|
test('controller test', controller_unit_test,
|
|
suite: 'controller',
|
|
timeout: 300,
|
|
env: ['ASAN_OPTIONS=detect_leaks=0'])
|
|
|