Skip to content

refactor: improve node DB state management and readiness logic#3932

Merged
jamesarich merged 1 commit into
mainfrom
fix/nodedb-install
Dec 8, 2025
Merged

refactor: improve node DB state management and readiness logic#3932
jamesarich merged 1 commit into
mainfrom
fix/nodedb-install

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

This pull request refactors the node database readiness and update logic in the MeshService class to improve clarity and reliability when handling node database state transitions. The main changes include renaming and splitting node DB state flags, updating the node info installation and completion process, and ensuring more robust batch updates and state transitions.

resolves #3898
replaces #3899

This commit refactors the node database handling within `MeshService` to improve performance and reliability during initial configuration synchronization.

Previously, each `NodeInfo` received from the device was individually written to the database, leading to multiple transactions. This could be slow and inefficient, especially on startup.

The key changes are:
- Introduced a batch update mechanism for the initial node list. Instead of writing each node to the database one by one, all nodes are now collected and saved in a single transaction when the `NodeInfoComplete` signal is received.
- The `haveNodeDB` flag has been split into two more descriptive flags:
    - `isNodeDbReady`: Signals that the initial node database is synchronized and ready for use.
    - `allowNodeDbWrites`: Controls when individual node updates can be written to the persistent database, which is enabled only after the initial batch-write is complete.
- `updateNodeInfo()` now includes a `withBroadcast` parameter to prevent unnecessary broadcasts and database writes during the initial batch processing.
- The `myNodeInfo` object is now updated more reliably from the `nodeRepository` flow at service start.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@codecov

codecov Bot commented Dec 8, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.52%. Comparing base (9246b3b) to head (201ce37).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...in/java/com/geeksville/mesh/service/MeshService.kt 0.00% 33 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #3932      +/-   ##
========================================
- Coverage   0.52%   0.52%   -0.01%     
========================================
  Files        394     394              
  Lines      23136   23141       +5     
  Branches    2933    2933              
========================================
  Hits         122     122              
- Misses     22993   22998       +5     
  Partials      21      21              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamesarich jamesarich added this pull request to the merge queue Dec 8, 2025
Merged via the queue into main with commit db0ae13 Dec 8, 2025
8 checks passed
@jamesarich jamesarich deleted the fix/nodedb-install branch December 8, 2025 21:53
@b8b8 b8b8 mentioned this pull request Dec 10, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Node list omits nodes from downloaded node DB

1 participant