Skip to content

Commit de553c2

Browse files
authored
Limit annotation update transactions to 1M actions (#8866)
Allocating the string for the serialized json caused an OutOfMemoryError for huge transactions. 1M actions is already a bit much anyway. We should rather create actions that edit multiple things. ### Steps to test: - Lower the limit to e.g. 10 - Brush some, should create >10 updateBucket actions - hit save, should be rejected ### Issues: - workaround for #8788
1 parent 984e781 commit de553c2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

unreleased_changes/8866.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Changed
2+
- Added protection against server outages by limiting the number of update actions in an annotation update transaction to 1000000.

webknossos-tracingstore/app/com/scalableminds/webknossos/tracingstore/annotation/AnnotationTransactionService.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ class AnnotationTransactionService @Inject()(handledGroupIdStore: TracingStoreRe
222222
implicit ec: ExecutionContext,
223223
tc: TokenContext): Fox[Unit] =
224224
for {
225-
updateActionsJson <- Fox.successful(Json.toJson(preprocessActionsForStorage(updateActionGroup)))
225+
updateActionsProcessed <- Fox.successful(preprocessActionsForStorage(updateActionGroup))
226+
_ <- Fox.fromBool(updateActionsProcessed.length <= 1000000) ?~> "Annotation update transactions with more than 1M update actions are not currently supported"
227+
updateActionsJson = Json.toJson(updateActionsProcessed)
226228
_ <- tracingDataStore.annotationUpdates.put(annotationId.toString, updateActionGroup.version, updateActionsJson)
227229
bucketMutatingActions = findBucketMutatingActions(updateActionGroup)
228230
actionsGrouped: Map[String, List[BucketMutatingVolumeUpdateAction]] = bucketMutatingActions.groupBy(

0 commit comments

Comments
 (0)