why tf job creation is not part of the transaction with LOCK
@@ -76,7 +76,7 @@ impl<'a> ProverSchema<'a> {
block_size: usize,
) -> QueryResult<Option<ProverRun>> {
// Select the block to prove.
- let job: Option<BlockNumber> = self
+ self
.0
.conn()
.transaction(|| {
@@ -106,8 +106,7 @@ impl<'a> ProverSchema<'a> {
);
// Return the index of such a block.
- diesel::sql_query(query).get_result::<Option<IntegerNumber>>(self.0.conn())
- })?
+ let job = diesel::sql_query(query).get_result::<Option<IntegerNumber>>(self.0.conn())?
.map(|i| i.integer_value as BlockNumber);
// If there is a block to prove, create a job and store it
@@ -124,6 +123,7 @@ impl<'a> ProverSchema<'a> {
} else {
Ok(None)
}
+ })
}
/// Updates the state of ongoing prover job.
