{{ message }}
Updating db handlers for orphan insertions and batched queries #478
Open
Sansh2356 wants to merge 3 commits into
Open
Updating db handlers for orphan insertions and batched queries #478Sansh2356 wants to merge 3 commits into
Sansh2356 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates node-side persistence to use batched DB insert commands (including persistence of newly-adopted orphans) and removes the legacy sequential insertion path, while adding helper types/logic to resolve parent references for DB writes and introducing new consensus/persistence error variants.
Changes:
- Replaces sequential DB insertion with a batched
InsertBeadsBatchcommand usingBeadInsertData(bead + id + resolved parent refs/timestamps). - Adds
Braid::resolve_parents()and newBraidErrorvariants to surface missing-parent / missing-index invariants during persistence resolution. - Updates startup DB loading and multiple persistence call sites to use the new batch API, plus updates DB tests to exercise the production batch insertion path.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
Comments suppressed due to low confidence (1)
node/src/db/db_handlers.rs:745
- This
use crate::{ ... }block importsbraidandemit_bead, but neither is used by the current test module. Consider collapsing the import to only what is needed.
use crate::{
braid,
utils::test_utils::test_utility_functions::{
emit_bead, loading_braid_from_file, BRAIDTESTDIRECTORY,
},
| pub struct DBHandler { | ||
| //Query receiver inherit to handler only | ||
| receiver: Receiver<BraidpoolDBTypes>, | ||
| //Shared across tasks for accessing DB after contention using `Mutex` |
| "parent": *parent_id, | ||
| "timestamp": *parent_timestamp, | ||
| })); | ||
| debug!("Parent found with id - {:?}", parent_id); |
Comment on lines
+695
to
+700
| let parent_ts = MedianTimePast::from_u32(parent_timestamp as u32).map_err(|e| { | ||
| DBErrors::TupleAttributeParsingError { | ||
| error: format!("Invalid parent timestamp value {}: {}", parent_timestamp, e), | ||
| attribute: "parent_bead_timestamps".to_string(), | ||
| } | ||
| })?; |
Comment on lines
735
to
739
| use super::*; | ||
| use serde_json::json; | ||
| use sqlx::{sqlite::SqliteConnectOptions, SqlitePool}; | ||
| use std::collections::HashSet; | ||
| use std::{fs, path::Path, str::FromStr}; |
Comment on lines
+792
to
+795
47a2021 to
e774ae6
Compare
… along with tests
Updating the test_batch_insertion for changed orphan handling with test orphan bead, adding error for ParentsNotFound and BeadIndexNotExists for additional error management. Updating the rollback error logging in db_handler.
e774ae6 to
7c00c64
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is a continuation of PR #309 and PR #474 having scope :-
SequentialQueryInsertion.Braidfor constructing parents set and passing intoBeadInsertDatacontaining parent_bead_idx and timestamp as per schema for insertion,to be passed onto the db_handler .