diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index eb53418f197..55950e1dc0d 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -28,6 +28,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - Fixed reading sharded Zarr 3 data from the local file system. [#7321](https://github.com/scalableminds/webknossos/pull/7321) - Fixed no-bucket data zipfile when downloading volume annotations. [#7323](https://github.com/scalableminds/webknossos/pull/7323) - Fixed too tight assertions when saving annotations, leading to failed save requests. [#7326](https://github.com/scalableminds/webknossos/pull/7326) +- Fixed a bug when saving large amounts of skeleton annotation data at once. [#7329](https://github.com/scalableminds/webknossos/pull/7329) ### Removed diff --git a/frontend/javascripts/oxalis/model/sagas/save_saga_constants.ts b/frontend/javascripts/oxalis/model/sagas/save_saga_constants.ts index 28d90432790..3633a96e587 100644 --- a/frontend/javascripts/oxalis/model/sagas/save_saga_constants.ts +++ b/frontend/javascripts/oxalis/model/sagas/save_saga_constants.ts @@ -14,11 +14,11 @@ export const SETTINGS_MAX_RETRY_COUNT = 20; // 20 * 15s == 5m export const MAXIMUM_ACTION_COUNT_PER_BATCH = { skeleton: 5000, volume: 1000, // Since volume saving is slower, use a lower value here. - mapping: 5000, + mapping: Infinity, // The back-end does not accept transactions for mappings. } as const; export const MAXIMUM_ACTION_COUNT_PER_SAVE = { skeleton: 15000, volume: 3000, - mapping: 15000, + mapping: Infinity, // The back-end does not accept transactions for mappings. } as const; diff --git a/webknossos-tracingstore/app/com/scalableminds/webknossos/tracingstore/controllers/TracingController.scala b/webknossos-tracingstore/app/com/scalableminds/webknossos/tracingstore/controllers/TracingController.scala index 77bc1dcdae4..cf28ab9e0f5 100644 --- a/webknossos-tracingstore/app/com/scalableminds/webknossos/tracingstore/controllers/TracingController.scala +++ b/webknossos-tracingstore/app/com/scalableminds/webknossos/tracingstore/controllers/TracingController.scala @@ -187,10 +187,29 @@ trait TracingController[T <: GeneratedMessage, Ts <: GeneratedMessage] extends C _ <- bool2Fox( previousActionGroupsToCommit .exists(_.transactionGroupIndex == 0) || updateGroup.transactionGroupCount == 1) ?~> s"Trying to commit a transaction without a group that has transactionGroupIndex 0." - commitResult <- commitUpdates(tracingId, previousActionGroupsToCommit :+ updateGroup, userToken) + concatenatedGroup = concatenateUpdateGroupsOfTransaction(previousActionGroupsToCommit, updateGroup) + commitResult <- commitUpdates(tracingId, List(concatenatedGroup), userToken) _ <- tracingService.removeAllUncommittedFor(tracingId, updateGroup.transactionId) } yield commitResult + private def concatenateUpdateGroupsOfTransaction(previousActionGroups: List[UpdateActionGroup[T]], + lastActionGroup: UpdateActionGroup[T]): UpdateActionGroup[T] = + if (previousActionGroups.isEmpty) lastActionGroup + else { + val allActionGroups = previousActionGroups :+ lastActionGroup + UpdateActionGroup[T]( + version = lastActionGroup.version, + timestamp = lastActionGroup.timestamp, + authorId = lastActionGroup.authorId, + actions = allActionGroups.flatMap(_.actions), + stats = lastActionGroup.stats, // the latest stats do count + info = lastActionGroup.info, // frontend sets this identically for all groups of transaction + transactionId = f"${lastActionGroup.transactionId}-concatenated", + transactionGroupCount = 1, + transactionGroupIndex = 0, + ) + } + // Perform version check and commit the passed updates private def commitUpdates(tracingId: String, updateGroups: List[UpdateActionGroup[T]], @@ -207,8 +226,7 @@ trait TracingController[T <: GeneratedMessage, Ts <: GeneratedMessage] extends C remoteWebKnossosClient.reportTracingUpdates(report).flatMap { _ => updateGroups.foldLeft(currentCommittedVersion) { (previousVersion, updateGroup) => previousVersion.flatMap { prevVersion: Long => - val versionIncrement = if (updateGroup.transactionGroupIndex == 0) 1 else 0 // version increment happens at the start of each transaction - if (prevVersion + versionIncrement == updateGroup.version) { + if (prevVersion + 1 == updateGroup.version) { tracingService .handleUpdateGroup(tracingId, updateGroup, prevVersion, userToken) .flatMap(