Ticket #12245 (confirmed Bug)

Opened 5 years ago

Last modified 4 years ago

CMFEditions checks for previous versions in a very inefficient way.

Reported by: rossp Owned by: alecm
Priority: minor Milestone: 4.x
Component: Versioning Version: 4.1
Keywords: Cc:

Description

CMFEditions can easily raise MemoryError when versioning is turned on for large files. Even when that is addressed, it's handling of BLOBs is very inefficient. This ticket is more for the latter problem as I intend to contribute a fix for the MemoryError issue.

CMFEditions tries to find out if this version is the first version by trying to retrieve a previous version. This seems a very inefficient way to do that and with BLOBs means the blob is copied several times.

The MemoryError occurs because Products.CMFEditions.ArchivistTool.ArchivistTool.retrieve() signals that there is no previous version by raising an error. When it instantiates that error it does a '"%s" % obj' string conversion on the object. When that object is a large blob, the string conversion loads the whole blob content into memory, hence the MemoryError. IOW, it wasn't even anything CMFEditions was *actually doing* that caused the MemoryError, it was the *way* CMFEditions tells itelf, "this object has no previous version".

CMFEditions should not be using "%s" string conversion for such errors anyways so the easy fix is to use repr() string conversion with "%r" which does the right thing. I've tested this locally and it does indeed resolve the MemoryError. I'll be committing tests and this fix soon.

Concerning the inefficiency of how CMFEditions checks for previous versions, what's the right way to check for the existence of a previous version without copying the blobs?

Change History

comment:1 Changed 4 years ago by kleist

Plone version please?

comment:2 Changed 4 years ago by rossp

Plone 3.3 and 4.1

comment:3 Changed 4 years ago by kleist

  • Milestone set to 4.x

comment:4 Changed 4 years ago by kleist

  • Status changed from new to confirmed
  • Version set to 4.1

comment:5 Changed 4 years ago by kleist

  • Summary changed from CMFEditions mishandling BLOBs to CMFEditions checks for previous versions in a very inefficient way.

The fix "CMFEditions should not be using "%s" string conversion for such errors anyways so the easy fix is to use repr() string conversion with "%r" which does the right thing." has obviously been applied:

 https://github.com/plone/Products.CMFEditions/blob/master/Products/CMFEditions/ArchivistTool.py#L342

Remains "Concerning the inefficiency of how CMFEditions checks for previous versions".

Note: See TracTickets for help on using tickets.