zopefoundation / ZODB

Python object-oriented database
https://zodb-docs.readthedocs.io/
Other
672 stars 90 forks source link

The ZODB should create the "tmp" directory for savepoint automatically if the target directory does not exist. #394

Open zopyx opened 10 months ago

zopyx commented 10 months ago

A savepoint() call may cause the error

  File "/home/ajung/src/unibo/magazine-plone6/eggs/transaction-3.1.0-py3.11.egg/transaction/_transaction.py", line 627, in __init__
    savepoint = savepoint()
                ^^^^^^^^^^^
  File "/home/ajung/src/unibo/magazine-plone6/eggs/ZODB-5.8.1-py3.11.egg/ZODB/Connection.py", line 984, in savepoint
    self._commit(None)
  File "/home/ajung/src/unibo/magazine-plone6/eggs/ZODB-5.8.1-py3.11.egg/ZODB/Connection.py", line 544, in _commit
    self._store_objects(ObjectWriter(obj), transaction)
  File "/home/ajung/src/unibo/magazine-plone6/eggs/ZODB-5.8.1-py3.11.egg/ZODB/Connection.py", line 591, in _store_objects
    s = self._storage.storeBlob(oid, serial, p, blobfilename,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ajung/src/unibo/magazine-plone6/eggs/ZODB-5.8.1-py3.11.egg/ZODB/Connection.py", line 1186, in storeBlob
    targetpath = self._getBlobPath()
                 ^^^^^^^^^^^^^^^^^^^
  File "/home/ajung/src/unibo/magazine-plone6/eggs/ZODB-5.8.1-py3.11.egg/ZODB/Connection.py", line 1215, in _getBlobPath
    blob_dir = tempfile.mkdtemp(dir=self.temporaryDirectory(),

if the target directory does not exist. Better: the directory should be created automatically rather than failing implicitly.

davisagli commented 10 months ago

What was the error at the end of the traceback?

zopyx commented 10 months ago

Sorry for incomplete information.

The savepoints for blobs are created (by default) inside var/blobstorage/tmp. Only var/blobstorage existed.

This is also true in other contexts where the ZODB/Zope expects directory to exist for var/logs, var/instance, var/filestorage etc.

davisagli commented 10 months ago

@zopyx What storages is your ZODB configured with?

From what I can see this temporary directory should normally be created when the blob storage is initialized: https://github.com/zopefoundation/ZODB/blob/master/src/ZODB/blob.py#L377-L378