Couple of bugs when deleting posts
Hi @KajMagnus
I'm seeing this error when trying to delete this post:
https://forum.soundflow.org/-7903#post-2
Something went wrong: [DwE500REX]
java.lang.IllegalArgumentException: requirement failed: Fail: 0 <= -1 [EsE0GY42B] page id: '7903', ext id: 'None'
at scala.Predef$.require(Predef.scala:281)
at com.debiki.core.PageMeta.<init>(Page.scala:313)
at com.debiki.core.PageMeta.copy(Page.scala:259)
at debiki.dao.PostsDao.changePostStatusImpl(PostsDao.scala:1938)
at debiki.dao.PostsDao.changePostStatusImpl$(PostsDao.scala:1708)
at debiki.dao.SiteDao.changePostStatusImpl(SiteDao.scala:113)
at debiki.dao.PostsDao.$anonfun$changePostStatus$1(PostsDao.scala:1694)
at debiki.dao.SiteDao.$anonfun$writeTx$2(SiteDao.scala:262)
at debiki.dao.SiteDao.$anonfun$readWriteTransaction$2(SiteDao.scala:302)
at com.debiki.core.DbDao2.readWriteSiteTransaction(DbDao2.scala:67)
at debiki.dao.SiteDao.$anonfun$readWriteTransaction$1(SiteDao.scala:302)
at debiki.dao.SiteDao$.siteWriteLockIdImpl(SiteDao.scala:814)
at debiki.dao.SiteDao$.$anonfun$withSiteWriteLock$1(SiteDao.scala:803)
at debiki.dao.SystemDao$.withWholeDbReadLock(SystemDao.scala:876)
at debiki.dao.SiteDao$.withSiteWriteLock(SiteDao.scala:803)
at debiki.dao.SiteDao.readWriteTransaction(SiteDao.scala:301)
at debiki.dao.SiteDao.writeTx(SiteDao.scala:278)
at debiki.dao.SiteDao.writeTx(SiteDao.scala:249)
at debiki.dao.PostsDao.changePostStatus(PostsDao.scala:1692)
at debiki.dao.PostsDao.changePostStatus$(PostsDao.scala:1689)
at debiki.dao.SiteDao.changePostStatus(SiteDao.scala:113)
at controllers.EditController.$anonfun$deletePost$1(EditController.scala:360)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at talkyard.server.http.PlainApiActions$$anon$1.runBlockIfAuthOk(PlainApiActions.scala:699)
at talkyard.server.http.PlainApiActions$$anon$1.invokeBlockAuthViaCookie(PlainApiActions.scala:447)
at talkyard.server.http.PlainApiActions$$anon$1.invokeBlockImpl(PlainApiActions.scala:250)
at talkyard.server.http.PlainApiActions$$anon$1.invokeBlock(PlainApiActions.scala:136)
at talkyard.server.http.PlainApiActions$$anon$1.invokeBlock(PlainApiActions.scala:109)
at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:379)
at talkyard.server.http.PlainApiActions$$anon$1.$anonfun$composeAction$1(PlainApiActions.scala:123)
at talkyard.server.http.SafeActions$ExceptionAction$.invokeBlock(SafeActions.scala:126)
at talkyard.server.http.SafeActions$ExceptionAction$.invokeBlock(SafeActions.scala:83)
at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:379)
at play.api.mvc.Action.$anonfun$apply$4(Action.scala:82)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$4(Accumulator.scala:168)
at scala.util.Try$.apply(Try.scala:213)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$3(Accumulator.scala:168)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at play.api.libs.streams.StrictAccumulator.run(Accumulator.scala:200)
at play.core.server.AkkaHttpServer.$anonfun$runAction$4(AkkaHttpServer.scala:418)
at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
at akka.http.scaladsl.util.FastFuture$.$anonfun$transformWith$3(FastFuture.scala:51)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:63)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:100)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:100)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
- CChristian Scheuer @chrscheuer
It's also impossible to pin the thread:
Something went wrong: [DwE500REX] java.lang.RuntimeException: pageMeta.numPostsTotal is 3 but should be = postNr + 1 = 4 [EdE3PFK2W0] at com.debiki.core.Prelude$.die(Prelude.scala:254) at com.debiki.core.Prelude$.dieIf(Prelude.scala:274) at debiki.dao.PagesDao.addMetaMessage(PagesDao.scala:793) at debiki.dao.PagesDao.addMetaMessage$(PagesDao.scala:769) at debiki.dao.SiteDao.addMetaMessage(SiteDao.scala:113) at debiki.dao.PagesDao.$anonfun$pinOrUnpin$2(PagesDao.scala:463) at debiki.dao.SiteDao.$anonfun$readWriteTransaction$2(SiteDao.scala:302) at com.debiki.core.DbDao2.readWriteSiteTransaction(DbDao2.scala:67) at debiki.dao.SiteDao.$anonfun$readWriteTransaction$1(SiteDao.scala:302) at debiki.dao.SiteDao$.siteWriteLockIdImpl(SiteDao.scala:814) at debiki.dao.SiteDao$.$anonfun$withSiteWriteLock$1(SiteDao.scala:803) at debiki.dao.SystemDao$.withWholeDbReadLock(SystemDao.scala:876) at debiki.dao.SiteDao$.withSiteWriteLock(SiteDao.scala:803) at debiki.dao.SiteDao.readWriteTransaction(SiteDao.scala:301) at debiki.dao.PagesDao.pinOrUnpin(PagesDao.scala:456) at debiki.dao.PagesDao.pinPage(PagesDao.scala:444) at debiki.dao.PagesDao.pinPage$(PagesDao.scala:443) at debiki.dao.SiteDao.pinPage(SiteDao.scala:113) at controllers.PageController.$anonfun$pinPage$1(PageController.scala:221) at scala.Function1.$anonfun$andThen$1(Function1.scala:57) at talkyard.server.http.PlainApiActions$$anon$1.runBlockIfAuthOk(PlainApiActions.scala:699) at talkyard.server.http.PlainApiActions$$anon$1.invokeBlockAuthViaCookie(PlainApiActions.scala:447) at talkyard.server.http.PlainApiActions$$anon$1.invokeBlockImpl(PlainApiActions.scala:250) at talkyard.server.http.PlainApiActions$$anon$1.invokeBlock(PlainApiActions.scala:136) at talkyard.server.http.PlainApiActions$$anon$1.invokeBlock(PlainApiActions.scala:109) at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:379) at talkyard.server.http.PlainApiActions$$anon$1.$anonfun$composeAction$1(PlainApiActions.scala:123) at talkyard.server.http.SafeActions$ExceptionAction$.invokeBlock(SafeActions.scala:126) at talkyard.server.http.SafeActions$ExceptionAction$.invokeBlock(SafeActions.scala:83) at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:379) at play.api.mvc.Action.$anonfun$apply$4(Action.scala:82) at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$4(Accumulator.scala:168) at scala.util.Try$.apply(Try.scala:213) at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$3(Accumulator.scala:168) at scala.Function1.$anonfun$andThen$1(Function1.scala:57) at scala.Function1.$anonfun$andThen$1(Function1.scala:57) at play.api.libs.streams.StrictAccumulator.run(Accumulator.scala:200) at play.core.server.AkkaHttpServer.$anonfun$runAction$4(AkkaHttpServer.scala:418) at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41) at akka.http.scaladsl.util.FastFuture$.$anonfun$transformWith$3(FastFuture.scala:51) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64) at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:63) at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:100) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85) at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:100) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
I think this comes from numPostsTotal not being updated correctly when we use the API to add posts to a page.
- CChristian Scheuer @chrscheuer
I could make this work again by manually replying to one of the posts (the API generated one) and then deleting each one.
- In reply tochrscheuer⬆:KajMagnus @KajMagnus2022-06-22 12:30:53.475Z
Seems in some API code path I forgot to call some counter update function, and then the above assertion fails, but not until now when deleting the post.
Note to myself: Here's the assertion:
require(numOrigPostRepliesVisible <= numRepliesVisible, s"Fail: $numOrigPostRepliesVisible <= $numRepliesVisible [EsE0GY42B] $wp")
impossible to pin the thread
This is another assertion, probably failing because of the same underlying issue.
I could make this work again by manually replying to one of the posts
Probably the counters get updated properly then, and thereafter the assertion won't fail. (I'm surprised you figured out that replying-then-deleting might work b.t.w.? :- ))
Thanks for reporting
Edit:
I think this comes from numPostsTotal not being updated correctly when we use the API
Aha, yes :- ) sorry for the troubles
- Progresswith handling this problem