tumblr / collins

groovy kind of love
tumblr.github.com/collins
Apache License 2.0
572 stars 99 forks source link

[solr] Indexing asset log fails if asset has not yet been indexed #528

Open byxorna opened 7 years ago

byxorna commented 7 years ago

If you create a new asset, and then immediately generate some logs on the asset before the asset doc has been fully indexed by Solr, the AssetLogSolrUpdater will raise the following exception, because the AssetLogSerializer is reading assetTag, which is defined thusly:

   88   @Transient
   89   lazy val assetTag: String = asset.tag
+  90   // TODO(gabe): if this log is indexed (serialized first) before solr is
+  91   // updated with the asset document, this will throw! This can happen when
+  92   // creating a new asset then immediately performing some attribute sets
+  93   // which create logs.
   94   @Transient
   95   lazy val asset: Asset = Asset.findById(assetId).get
2017-03-10 16:09:36,108 - [ERROR] - SolrPlugin - p.a.LoggerLike$class:error:131 - Added 1 asset documents to be indexed within 200 ms
[ERROR] [03/10/2017 16:09:57.680] [application-akka.actor.default-dispatcher-2] [akka://application/user/change_queue_processor] None.get
java.util.NoSuchElementException: None.get
        at scala.None$.get(Option.scala:347)
        at scala.None$.get(Option.scala:345)
        at collins.models.AssetMetaValue.asset$lzycompute(AssetMetaValue.scala:30)
        at collins.models.AssetMetaValue.asset(AssetMetaValue.scala:30)
        at collins.solr.SolrAssetCallbackHandler.processValue(SolrCallbackHandler.scala:33)
        at collins.solr.SolrAssetCallbackHandler.apply(SolrCallbackHandler.scala:24)
        at collins.callbacks.CallbackManager$$anon$1.propertyChange(CallbackManager.scala:21)
        at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:328)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
        at collins.callbacks.CallbackMessageQueue$$anonfun$receive$1.applyOrElse(CallbackMessageQueue.scala:14)
        at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
        at collins.callbacks.CallbackMessageQueue.aroundReceive(CallbackMessageQueue.scala:9)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
        at akka.actor.ActorCell.invoke(ActorCell.scala:487)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
        at akka.dispatch.Mailbox.run(Mailbox.scala:220)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)