Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

## v0.2.1 (2026-04-05)

### Fixes
### Bug Fixes

- Fixed `:crypto` and `:eex` missing from release by adding them to `extra_applications`.
- Fixed `runtime.exs` network interface lookup to fall back to `iface0` (e.g. `lo0` on macOS).
- Clearer error message when a node fails to start because it was registered under a different name during initial bootstrap.
- Fixed erlexec command arguments to pass charlists instead of binaries, matching the declared `cmd()` type spec. This resolved all dialyzer `no_return` warnings and removed the need for any dialyzer ignore entries.

### Improvements
### Enhancements

- Added `ExFdbmonitor.Binaries` module: centralises FDB binary path resolution with OS-aware defaults for Darwin and Linux, falling back to application config when set.
- `ExFdbmonitor.Fdbcli.exec/3` gains a `:timeout` option (milliseconds) and a `:stderr` option for controlling which streams are captured.
- Added GitHub Actions CI with lint and test jobs.

### Dependencies

- Updated erlfdb to 1.1
- Updated dgen to main branch (pending release of 0.3)

## v0.2.0 (2026-02-27)

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_fdbmonitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule ExFdbmonitor do
@doc """
Gracefully remove the current node from the cluster.

Executes `MgmtServer.scale_down/1` which, under the DGenServer lock:
Executes `MgmtServer.scale_down/1` which, under the DGen.Server lock:

1. Downgrades the redundancy mode if the remaining nodes can no longer
sustain it (e.g. triple → double when dropping below 5 nodes).
Expand Down
36 changes: 18 additions & 18 deletions lib/ex_fdbmonitor/mgmt_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ require Logger

defmodule ExFdbmonitor.MgmtServer do
@moduledoc """
A DGenServer that serializes actions across all nodes.
A DGen.Server that serializes actions across all nodes.

Nodes submit fdbcli commands via `exec/1`. The DGenServer processes
Nodes submit fdbcli commands via `exec/1`. The DGen.Server processes
them one at a time, ensuring commands from different nodes don't
interleave on a cluster that is still being configured.
"""

use DGenServer
use DGen.Server

defstruct nodes: %{}, redundancy_mode: nil

Expand All @@ -21,7 +21,7 @@ defmodule ExFdbmonitor.MgmtServer do
@mode_order %{"single" => 1, "double" => 2, "triple" => 3}

def start_link({db, dir}) do
DGenServer.start_link(__MODULE__, [],
DGen.Server.start_link(__MODULE__, [],
name: __MODULE__,
tenant: {db, dir},
dead_letter_threshold: :infinity
Expand All @@ -32,21 +32,21 @@ defmodule ExFdbmonitor.MgmtServer do
Execute `fdbcli_args` through the serialized server.
"""
def exec(fdbcli_args) do
DGenServer.call(__MODULE__, {:exec, fdbcli_args}, :infinity)
DGen.Server.call(__MODULE__, {:exec, fdbcli_args}, :infinity)
end

@doc """
Register a mapping from `machine_id` to `node_name` in the server state.
"""
def register_node(machine_id, node_name) do
DGenServer.call(__MODULE__, {:register_node, machine_id, node_name}, :infinity)
DGen.Server.call(__MODULE__, {:register_node, machine_id, node_name}, :infinity)
end

@doc """
Look up the machine_id for a given node name.
"""
def get_machine_id(node_name) do
DGenServer.call(__MODULE__, {:get_machine_id, node_name}, :infinity)
DGen.Server.call(__MODULE__, {:get_machine_id, node_name}, :infinity)
end

@doc """
Expand All @@ -55,7 +55,7 @@ defmodule ExFdbmonitor.MgmtServer do
Raises if the node has no registered machine_id.
"""
def exclude(node_name) do
DGenServer.call(__MODULE__, {:exclude, node_name}, :infinity)
DGen.Server.call(__MODULE__, {:exclude, node_name}, :infinity)
end

@doc """
Expand All @@ -64,15 +64,15 @@ defmodule ExFdbmonitor.MgmtServer do
Returns `{:error, {:unknown_node, node_name}}` if the node has no registered machine_id.
"""
def include(node_name) do
DGenServer.call(__MODULE__, {:include, node_name}, :infinity)
DGen.Server.call(__MODULE__, {:include, node_name}, :infinity)
end

@doc """
Gracefully remove `nodes_to_exclude` from the cluster.

Automatically determines the appropriate redundancy mode for the
surviving nodes and downgrades if necessary. Executes under the
DGenServer lock:
DGen.Server lock:
1. `configure <mode>` (only if downgrade needed)
2. Set coordinators to surviving nodes
3. `exclude` each departing node (blocks until data moved)
Expand All @@ -81,7 +81,7 @@ defmodule ExFdbmonitor.MgmtServer do
after this call returns.
"""
def scale_down(nodes_to_exclude) do
DGenServer.call(__MODULE__, {:scale_down, nodes_to_exclude}, :infinity)
DGen.Server.call(__MODULE__, {:scale_down, nodes_to_exclude}, :infinity)
end

@doc """
Expand All @@ -99,10 +99,10 @@ defmodule ExFdbmonitor.MgmtServer do
before the threshold is met are no-ops.
"""
def scale_up(target_mode, nodes_to_include) do
DGenServer.call(__MODULE__, {:scale_up, target_mode, nodes_to_include}, :infinity)
DGen.Server.call(__MODULE__, {:scale_up, target_mode, nodes_to_include}, :infinity)
end

# --- DGenServer callbacks ---
# --- DGen.Server callbacks ---

@impl true
def init([]), do: {:ok, @tuid, %__MODULE__{}}
Expand Down Expand Up @@ -182,29 +182,29 @@ defmodule ExFdbmonitor.MgmtServer do
end

@impl true
def handle_locked({:call, _from}, {:exec, fdbcli_args}, state) do
def handle_locked(_db_ctx, {:call, _from}, {:exec, fdbcli_args}, state) do
Logger.notice("#{node()} fdbcli server exec #{inspect(fdbcli_args)}")
result = ExFdbmonitor.Fdbcli.exec(fdbcli_args)
{:reply, result, state}
end

def handle_locked({:call, _from}, {:exclude, node_name}, state) do
def handle_locked(_db_ctx, {:call, _from}, {:exclude, node_name}, state) do
machine_id = state.nodes[node_name]
fdbcli_args = ["exclude", "locality_machineid:#{machine_id}"]
Logger.notice("#{node()} fdbcli server exec #{inspect(fdbcli_args)}")
result = ExFdbmonitor.Fdbcli.exec(fdbcli_args)
{:reply, result, state}
end

def handle_locked({:call, _from}, {:include, node_name}, state) do
def handle_locked(_db_ctx, {:call, _from}, {:include, node_name}, state) do
machine_id = state.nodes[node_name]
fdbcli_args = ["include", "locality_machineid:#{machine_id}"]
Logger.notice("#{node()} fdbcli server exec #{inspect(fdbcli_args)}")
result = ExFdbmonitor.Fdbcli.exec(fdbcli_args)
{:reply, result, state}
end

def handle_locked({:call, _from}, {:scale_down, nodes_to_exclude}, state) do
def handle_locked(_db_ctx, {:call, _from}, {:scale_down, nodes_to_exclude}, state) do
surviving = Map.keys(state.nodes) -- nodes_to_exclude
current = current_redundancy_mode()
target = target_mode(length(surviving), state)
Expand All @@ -218,7 +218,7 @@ defmodule ExFdbmonitor.MgmtServer do
end
end

def handle_locked({:call, _from}, {:scale_up, _target_mode, nodes_to_include}, state) do
def handle_locked(_db_ctx, {:call, _from}, {:scale_up, _target_mode, nodes_to_include}, state) do
mode = state.redundancy_mode
current = current_redundancy_mode()

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule ExFdbmonitor.MixProject do
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.16", only: :dev, runtime: false},
{:erlfdb, "~> 1.0"},
{:dgen, "~> 0.2"}
{:dgen, github: "foundationdb-beam/dgen"}
]
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"credo": {:hex, :credo, "1.7.17", "f92b6aa5b26301eaa5a35e4d48ebf5aa1e7094ac00ae38f87086c562caf8a22f", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1eb5645c835f0b6c9b5410f94b5a185057bcf6d62a9c2b476da971cde8749645"},
"dgen": {:hex, :dgen, "0.2.0", "e0a4d9b1204c6509bfa6691071a1bcb7c9cb08ec6188821d38d4b40fc93af9b0", [:mix, :rebar3], [{:erlfdb, "~> 1.0", [hex: :erlfdb, repo: "hexpm", optional: true]}], "hexpm", "9bff251be1847ded39a8d51cd2bccac5eedc86bfa9e119a992d0ce1945357384"},
"dgen": {:git, "https://github.com/foundationdb-beam/dgen.git", "d4bd0729bb2ac90b2ab34faa1a7a5b930728eb8b", []},
"dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"},
"earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"},
"erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"},
Expand Down
Loading