Skip to content
Snippets Groups Projects
Commit 2c1a7878 authored by asynchronous rob's avatar asynchronous rob Committed by GitHub
Browse files

fix bug where we over-eagerly remove backing spans for candidates we validate ourselves (#2142)

* fix bug where we over-eagerly remove backing spans for candidates we validate ourselves

* jaeger: watch importing of statements
parent a141a6fb
Branches
No related merge requests found
...@@ -503,7 +503,6 @@ impl CandidateBackingJob { ...@@ -503,7 +503,6 @@ impl CandidateBackingJob {
) -> Result<(), Error> { ) -> Result<(), Error> {
let candidate_hash = command.candidate_hash(); let candidate_hash = command.candidate_hash();
self.awaiting_validation.remove(&candidate_hash); self.awaiting_validation.remove(&candidate_hash);
self.remove_unbacked_span(&candidate_hash);
match command { match command {
ValidatedCandidateCommand::Second(res) => { ValidatedCandidateCommand::Second(res) => {
...@@ -664,6 +663,12 @@ impl CandidateBackingJob { ...@@ -664,6 +663,12 @@ impl CandidateBackingJob {
&mut self, &mut self,
statement: &SignedFullStatement, statement: &SignedFullStatement,
) -> Result<Option<TableSummary>, Error> { ) -> Result<Option<TableSummary>, Error> {
let _span = {
// create a span only for candidates we're already aware of.
let candidate_hash = statement.payload().candidate_hash();
self.get_unbacked_statement_child(&candidate_hash, statement.validator_index())
};
let stmt = primitive_statement_to_table(statement); let stmt = primitive_statement_to_table(statement);
let summary = self.table.import_statement(&self.table_context, stmt); let summary = self.table.import_statement(&self.table_context, stmt);
...@@ -854,6 +859,14 @@ impl CandidateBackingJob { ...@@ -854,6 +859,14 @@ impl CandidateBackingJob {
self.unbacked_candidates.get(hash).map(|span| span.child("validation")) self.unbacked_candidates.get(hash).map(|span| span.child("validation"))
} }
fn get_unbacked_statement_child(&self, hash: &CandidateHash, validator: ValidatorIndex) -> Option<JaegerSpan> {
self.unbacked_candidates.get(hash).map(|span| {
let mut span = span.child("import-statement");
span.add_string_tag("validator-index", &format!("{}", validator));
span
})
}
fn remove_unbacked_span(&mut self, hash: &CandidateHash) { fn remove_unbacked_span(&mut self, hash: &CandidateHash) {
self.unbacked_candidates.remove(hash); self.unbacked_candidates.remove(hash);
} }
......
...@@ -63,6 +63,17 @@ pub enum Statement { ...@@ -63,6 +63,17 @@ pub enum Statement {
} }
impl Statement { impl Statement {
/// Get the candidate hash referenced by this statement.
///
/// If this is a `Statement::Seconded`, this does hash the candidate receipt, which may be expensive
/// for large candidates.
pub fn candidate_hash(&self) -> CandidateHash {
match *self {
Statement::Valid(ref h) | Statement::Invalid(ref h) => *h,
Statement::Seconded(ref c) => c.hash(),
}
}
/// Transform this statement into its compact version, which references only the hash /// Transform this statement into its compact version, which references only the hash
/// of the candidate. /// of the candidate.
pub fn to_compact(&self) -> CompactStatement { pub fn to_compact(&self) -> CompactStatement {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment