rabbah commented on a change in pull request #2832: Do not cache invalidate
when adding a DB attachment
URL:
https://github.com/apache/incubator-openwhisk/pull/2832#discussion_r154921658
##########
File path:
common/scala/src/main/scala/whisk/core/database/DocumentFactory.scala
##########
@@ -178,12 +134,13 @@ trait DocumentFactory[W] extends
MultipleReadersSingleWriterCache[W, DocInfo] {
implicit val logger = db.logging
implicit val ec = db.executionContext
- val key = CacheKey(doc.id.asDocInfo)
- // invalidate the key because attachments update the revision;
- // do not cache the new attachment (controller does not need it)
- cacheInvalidate(key, {
- val src = StreamConverters.fromInputStream(() => bytes)
- db.attach(doc, attachmentName, contentType, src)
+ val key = CacheKey(doc)
+ val docInfo = doc.docinfo
+ val src = StreamConverters.fromInputStream(() => bytes)
+
+ cacheUpdate(doc, key, db.attach(docInfo, attachmentName, contentType,
src) map { newDocInfo =>
Review comment:
I neee to check the locking on the to-be-updated doc; I think a write around
is allowed to race to the db and this future would only succeed if the locked
entity was updated. Since the attachment also holds the reference to the
revision of the locked entry, the cached document will be consistent on success
and invalidated on failure.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services