Skip to content

Commit

Permalink
Merge pull request #1964 from dedis/fix-be2-daniel-rumor-process-order
Browse files Browse the repository at this point in the history
Fix rumor process order
  • Loading branch information
K1li4nL authored Jun 28, 2024
2 parents 69b0e0a + 09141b2 commit 4b7ef79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions be2-scala/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<!--Configuration for ch.qos.logback-->
<!--Set debug to true to show debug logs on STDOUT-->
<configuration debug="false" scan="true" scanPeriod="15 seconds">
<akkaProperty name="AKKA_LOGLEVEL" path="akka.loglevel" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} - %highlight(%-5level) : %logger{0} > %msg%n</pattern>
</encoder>
</appender>

<logger name="ch.epfl.pop" level="INFO" additivity="false">
<appender-ref ref="STDOUT" />
</logger>

<!--Set root(general) logs level to INFO/DEBUG on STDOUT-->
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ object ProcessMessagesHandler extends AskPatternConstants {
case Some(rumorList) =>
val orderedRumors = rumorList.sortBy(_.timestamp)
var processedRumors: List[Rumor] = List.empty
var successful = true
for rumor <- orderedRumors if successful do {
successful = rumorHandler(messageRegistry, rumor) && writeRumorInDb(dbActorRef, rumor)
processedRumors = processedRumors.prepended(rumor)
for rumor <- orderedRumors do {
if writeRumorInDb(dbActorRef, rumor) && rumorHandler(messageRegistry, rumor) then
processedRumors = processedRumors.prepended(rumor)
}
if !successful then
system.log.info(s"Failed to process all rumors from rumorStateAnswer $jsonId. Processed rumors where ${processedRumors.map(rumor => (rumor.senderPk, rumor.rumorId)).tail}. Unprocessed rumors not written in memory.")
if processedRumors.size != orderedRumors.size then
system.log.info(s"Failed to process all rumors from rumorStateAnswer $jsonId. Processed rumors where ${if processedRumors.nonEmpty then processedRumors.map(rumor => (rumor.senderPk, rumor.rumorId)).tail else processedRumors}. Unprocessed rumors not written in memory.")
Left(PipelineError(
ErrorCodes.SERVER_ERROR.id,
s"Rumor state handler was not able to process all rumors from $msg",
Expand Down

0 comments on commit 4b7ef79

Please sign in to comment.