Skip to content

Commit

Permalink
[MBL-18139][Student][Teacher] Some page views are failing to upload #…
Browse files Browse the repository at this point in the history
…2680

refs: MBL-18139
affects: Student, Teacher
release note: none
  • Loading branch information
tamaskozmer authored Dec 17, 2024
1 parent 05758f3 commit 3bd502d
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,18 @@ abstract class PageViewUploadService : JobService() {
val orphanDate = Date(System.currentTimeMillis() - MAX_ORPHAN_AGE)
val maxAgeDate = Date(System.currentTimeMillis() - MAX_EVENT_AGE)
book.allKeys.asSequence()
.mapNotNull { book.read<PageViewEvent>(it) }
.mapNotNull {
try {
book.read<PageViewEvent>(it)
} catch (e: Exception) {
// This is a known issue in PaperDB that some deserializaton randomly fails due to Kyro
// https://github.com/pilgr/Paper/issues/4#issuecomment-740185776
// Suggested workaround is to try reading the object again
// They won't fix it because the library is not maintained anymore. Long term fix is to migrate to Room.
onException(Throwable("Failed to read PageViewEvent for the first try", e))
book.read<PageViewEvent>(it)
}
}
.filter { it.eventDuration > 0 || it.timestamp.before(orphanDate) }
.partition { it.timestamp.after(maxAgeDate) }
}
Expand Down

0 comments on commit 3bd502d

Please sign in to comment.