[xwiki-devs] [VOTE] Save dirty attachment content when saving documents
In XWiki(Hibernate|Jcr)Store#saveXWikiDoc(), the attachement list is persisted, but the attachement contents are not persisted. A) I would like to take care of also persisting attachment contents when these contents are loaded and marked dirty (XWikiAttachmentContent#isContentDirty() == true). Why I would like to change this ? 1) I see no use case that would have to persist reference to an attachment and drop its content at the same time, which create records with a size field set to n bytes, while the attachment is 0 or m bytes. 2) When for example an XWikiDocument#copy() is followed by an XWiki#saveDocument() (on the newly created document), without also calling XWikiDocument#saveAllAttachements(), the cache store contains the documents with all their attachments contents, while the DB has not really persisted these contents. 3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.) 4) isContentDirty is properly maintained, and currently it is nearly unused, making the false impression that attachments content are persisted properly 5) This issue is invisible in normal XWiki usage, since we take care of saving attachments contents to avoid it everywhere, for example in XWiki#copyDocument(), attachments contents are saved "manually". 6) As a application developer, using the internal API in groovy, my collegue has missed it, and we have loose production data, since during testing, the cache has always hide the issue. I really dislike API that could introduce inconsistencies in the DB and moreover when you loose large amount of data. B) This change has no real impact on any code that would take care of saving the attachments separatly, it will just be saved twice, isContentDirty() currently only prevent useless archiving. This could be optimized by not saving contents as well when it is not dirty, but I do not want a negative vote on the rest for just this. So please vote this as B) C) I also would like to optimize existing internal usage, removing useless call to saveAttachmentContent() in XWiki.copyDocument() for example. This could have an impact on a custom store that does not take care of saving attachments contents while saving documents. I doubt many user has such a store and release notes could mention this incompatibility. This is my +1 for A) B) and C) Denis -- Denis Gervalle SOFTEC sa - CEO eGuilde sarl - CTO
Hi, On Fri, Apr 2, 2010 at 1:38 PM, Denis Gervalle <[email protected]> wrote:
In XWiki(Hibernate|Jcr)Store#saveXWikiDoc(), the attachement list is persisted, but the attachement contents are not persisted. A) I would like to take care of also persisting attachment contents when these contents are loaded and marked dirty (XWikiAttachmentContent#isContentDirty() == true).
Why I would like to change this ?
1) I see no use case that would have to persist reference to an attachment and drop its content at the same time, which create records with a size field set to n bytes, while the attachment is 0 or m bytes. 2) When for example an XWikiDocument#copy() is followed by an XWiki#saveDocument() (on the newly created document), without also calling XWikiDocument#saveAllAttachements(), the cache store contains the documents with all their attachments contents, while the DB has not really persisted these contents. 3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.) 4) isContentDirty is properly maintained, and currently it is nearly unused, making the false impression that attachments content are persisted properly 5) This issue is invisible in normal XWiki usage, since we take care of saving attachments contents to avoid it everywhere, for example in XWiki#copyDocument(), attachments contents are saved "manually". 6) As a application developer, using the internal API in groovy, my collegue has missed it, and we have loose production data, since during testing, the cache has always hide the issue. I really dislike API that could introduce inconsistencies in the DB and moreover when you loose large amount of data.
I also faced the same problem. Now I have to manually invoke $doc.document.saveAttachmentContent($attach.attachment, $context.context) or something like that which is really ugly. So, big +1 from me. I wonder why it was implemented that way in the first place. Thanks. - Asiri
+1 Thanks, Marius Denis Gervalle wrote:
In XWiki(Hibernate|Jcr)Store#saveXWikiDoc(), the attachement list is persisted, but the attachement contents are not persisted. A) I would like to take care of also persisting attachment contents when these contents are loaded and marked dirty (XWikiAttachmentContent#isContentDirty() == true).
Why I would like to change this ?
1) I see no use case that would have to persist reference to an attachment and drop its content at the same time, which create records with a size field set to n bytes, while the attachment is 0 or m bytes. 2) When for example an XWikiDocument#copy() is followed by an XWiki#saveDocument() (on the newly created document), without also calling XWikiDocument#saveAllAttachements(), the cache store contains the documents with all their attachments contents, while the DB has not really persisted these contents. 3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.) 4) isContentDirty is properly maintained, and currently it is nearly unused, making the false impression that attachments content are persisted properly 5) This issue is invisible in normal XWiki usage, since we take care of saving attachments contents to avoid it everywhere, for example in XWiki#copyDocument(), attachments contents are saved "manually". 6) As a application developer, using the internal API in groovy, my collegue has missed it, and we have loose production data, since during testing, the cache has always hide the issue. I really dislike API that could introduce inconsistencies in the DB and moreover when you loose large amount of data.
B) This change has no real impact on any code that would take care of saving the attachments separatly, it will just be saved twice, isContentDirty() currently only prevent useless archiving. This could be optimized by not saving contents as well when it is not dirty, but I do not want a negative vote on the rest for just this. So please vote this as B)
C) I also would like to optimize existing internal usage, removing useless call to saveAttachmentContent() in XWiki.copyDocument() for example. This could have an impact on a custom store that does not take care of saving attachments contents while saving documents. I doubt many user has such a store and release notes could mention this incompatibility.
This is my +1 for A) B) and C)
Denis
+1 On Fri, Apr 2, 2010 at 10:08, Denis Gervalle <[email protected]> wrote:
In XWiki(Hibernate|Jcr)Store#saveXWikiDoc(), the attachement list is persisted, but the attachement contents are not persisted. A) I would like to take care of also persisting attachment contents when these contents are loaded and marked dirty (XWikiAttachmentContent#isContentDirty() == true).
Why I would like to change this ?
1) I see no use case that would have to persist reference to an attachment and drop its content at the same time, which create records with a size field set to n bytes, while the attachment is 0 or m bytes. 2) When for example an XWikiDocument#copy() is followed by an XWiki#saveDocument() (on the newly created document), without also calling XWikiDocument#saveAllAttachements(), the cache store contains the documents with all their attachments contents, while the DB has not really persisted these contents. 3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.) 4) isContentDirty is properly maintained, and currently it is nearly unused, making the false impression that attachments content are persisted properly 5) This issue is invisible in normal XWiki usage, since we take care of saving attachments contents to avoid it everywhere, for example in XWiki#copyDocument(), attachments contents are saved "manually". 6) As a application developer, using the internal API in groovy, my collegue has missed it, and we have loose production data, since during testing, the cache has always hide the issue. I really dislike API that could introduce inconsistencies in the DB and moreover when you loose large amount of data.
B) This change has no real impact on any code that would take care of saving the attachments separatly, it will just be saved twice, isContentDirty() currently only prevent useless archiving. This could be optimized by not saving contents as well when it is not dirty, but I do not want a negative vote on the rest for just this. So please vote this as B)
C) I also would like to optimize existing internal usage, removing useless call to saveAttachmentContent() in XWiki.copyDocument() for example. This could have an impact on a custom store that does not take care of saving attachments contents while saving documents. I doubt many user has such a store and release notes could mention this incompatibility.
This is my +1 for A) B) and C)
Denis
-- Denis Gervalle SOFTEC sa - CEO eGuilde sarl - CTO _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
+1 Caleb Denis Gervalle wrote:
In XWiki(Hibernate|Jcr)Store#saveXWikiDoc(), the attachement list is persisted, but the attachement contents are not persisted. A) I would like to take care of also persisting attachment contents when these contents are loaded and marked dirty (XWikiAttachmentContent#isContentDirty() == true).
Why I would like to change this ?
1) I see no use case that would have to persist reference to an attachment and drop its content at the same time, which create records with a size field set to n bytes, while the attachment is 0 or m bytes. 2) When for example an XWikiDocument#copy() is followed by an XWiki#saveDocument() (on the newly created document), without also calling XWikiDocument#saveAllAttachements(), the cache store contains the documents with all their attachments contents, while the DB has not really persisted these contents. 3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.) 4) isContentDirty is properly maintained, and currently it is nearly unused, making the false impression that attachments content are persisted properly 5) This issue is invisible in normal XWiki usage, since we take care of saving attachments contents to avoid it everywhere, for example in XWiki#copyDocument(), attachments contents are saved "manually". 6) As a application developer, using the internal API in groovy, my collegue has missed it, and we have loose production data, since during testing, the cache has always hide the issue. I really dislike API that could introduce inconsistencies in the DB and moreover when you loose large amount of data.
B) This change has no real impact on any code that would take care of saving the attachments separatly, it will just be saved twice, isContentDirty() currently only prevent useless archiving. This could be optimized by not saving contents as well when it is not dirty, but I do not want a negative vote on the rest for just this. So please vote this as B)
C) I also would like to optimize existing internal usage, removing useless call to saveAttachmentContent() in XWiki.copyDocument() for example. This could have an impact on a custom store that does not take care of saving attachments contents while saving documents. I doubt many user has such a store and release notes could mention this incompatibility.
This is my +1 for A) B) and C)
Denis
Results: 5 +1, no 0, no -1. The vote is passed and I have opened XWIKI-5078 ( http://jira.xwiki.org/jira/browse/XWIKI-5078). I will prepare a patch, not sure it will get in for 2.3M2, since I am not fully available this week. Thanks, Denis
On 04/02/2010 10:08 AM, Denis Gervalle wrote:
In XWiki(Hibernate|Jcr)Store#saveXWikiDoc(), the attachement list is persisted, but the attachement contents are not persisted. A) I would like to take care of also persisting attachment contents when these contents are loaded and marked dirty (XWikiAttachmentContent#isContentDirty() == true).
Why I would like to change this ?
1) I see no use case that would have to persist reference to an attachment and drop its content at the same time, which create records with a size field set to n bytes, while the attachment is 0 or m bytes. 2) When for example an XWikiDocument#copy() is followed by an XWiki#saveDocument() (on the newly created document), without also calling XWikiDocument#saveAllAttachements(), the cache store contains the documents with all their attachments contents, while the DB has not really persisted these contents. 3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.)
I don't like this either. I think there's an issue I created some time ago, but Jira is down right now so I can't find it.
4) isContentDirty is properly maintained, and currently it is nearly unused, making the false impression that attachments content are persisted properly 5) This issue is invisible in normal XWiki usage, since we take care of saving attachments contents to avoid it everywhere, for example in XWiki#copyDocument(), attachments contents are saved "manually". 6) As a application developer, using the internal API in groovy, my collegue has missed it, and we have loose production data, since during testing, the cache has always hide the issue. I really dislike API that could introduce inconsistencies in the DB and moreover when you loose large amount of data.
+1
B) This change has no real impact on any code that would take care of saving the attachments separatly, it will just be saved twice, isContentDirty() currently only prevent useless archiving. This could be optimized by not saving contents as well when it is not dirty, but I do not want a negative vote on the rest for just this. So please vote this as B)
I'm not sure that this is really a problem. As far as I've seen, all code that manually saves attachments also resets isContentDirty to false, so (most) manually saved attachments won't get saved again,
C) I also would like to optimize existing internal usage, removing useless call to saveAttachmentContent() in XWiki.copyDocument() for example. This could have an impact on a custom store that does not take care of saving attachments contents while saving documents. I doubt many user has such a store and release notes could mention this incompatibility.
+1
This is my +1 for A) B) and C)
Denis
-- Sergiu Dumitriu http://purl.org/net/sergiu/
On Mon, Apr 5, 2010 at 00:32, Sergiu Dumitriu <[email protected]> wrote:
On 04/02/2010 10:08 AM, Denis Gervalle wrote:
3) In XWikiHibernateAttachmentStore#saveAttachmentContent(), the default is to persist the document, this is not consistent with the document not doing the same in reverse. (I would have better understand that persisting attachment contents does not persist the document.)
I don't like this either. I think there's an issue I created some time ago, but Jira is down right now so I can't find it.
We agree but this is not so easy to be changed. I will look after your issue...
B) This change has no real impact on any code that would take care of saving the attachments separatly, it will just be saved twice, isContentDirty() currently only prevent useless archiving. This could be optimized by not saving contents as well when it is not dirty, but I do not want a negative vote on the rest for just this. So please vote this as B)
I'm not sure that this is really a problem. As far as I've seen, all code that manually saves attachments also resets isContentDirty to false, so (most) manually saved attachments won't get saved again,
Currently, isContentDirty on attachment content is only checked to avoid unneeded archiving, but persistence is done without taking care of it. I just want to put it back the way it should always been. I have just receive Sergiu vote after my results post, so for correctness the final result is: 6 +1, no 0, no -1 Thanks, Denis -- Denis Gervalle SOFTEC sa - CEO eGuilde sarl - CTO
participants (6)
-
Asiri Rathnayake -
Caleb James DeLisle -
Denis Gervalle -
Marius Dumitru Florea -
Sergiu Dumitriu -
Thomas Mortagne