Fix importSnapshot/exportSnapshot - #870
Conversation
147d411 to
be86e7f
Compare
be86e7f to
e1b7c75
Compare
This turns the single-value strict data types into newtypes and replaces their internal FsPath with an FsErrorPath.
…ource/target HasFS
e1b7c75 to
ceb6d62
Compare
There was a problem hiding this comment.
There are two general things to think about here:
-
If I create a session with
withOpenSessionIO, then I can still useimportSnapshot/exportSnapshotwithout providing a destination FS, which gets us back in unsafe territory where paths are interpreted with respect to the session directory. Maybe we can track a simpleBoolin theSessiontype that tracks whether the session was created inwithOpenSessionIO, and if it was, throw an error when a desination FS is not provided inimportSnapshot/exportSnapshot -
The hardlink with copy fallback is nice but has its downsides. it's not visible to the user if the fallback was used, or whether the files were hard linked. This is important to know, because changes to hard linked files are visible to all links, but not if the files were copied. Moreover, I think users will want to only hard link or only copy. So maybe we should have separate functions:
importSnapshotCopy(andimportSnapshotCopyIO)exportSnapshotCopy(andexportSnapshotCopyIO)importSnapshotHardlinkexportSnapshotHardlink
I intentionally left out
IOversions of the hard linking import/export functions, because we want to only allow copies for sessions that are created withwithOpenSessionIO. And maybe we should then add a new public error that captures theEXDEVerror, so that users can write something like this on top of thelsm-treelibrary: try hard link, and ifEXDEV, copy
There's much more unsafe stuff in the library that is only guarded by a library. I think a well written warning is sufficient, which I've added. |
|
015d2a2 to
79b5061
Compare
This PR addresses #853. It makes the following changes:
withOpenSessionIO.FsPathfield ofSnapshotImportDirDoesNotExistError/SnapshotExportDirExistsErrorwith anFsErrorPath.SnapshotImportDirDoesNotExistError/SnapshotExportDirExistsErrortoErrSnapshotImportDirDoesNotExist/ErrSnapshotExportDirExistsfor consistency with the rest of the exceptions defined by thelsm-treepackage.HasFSinstance to theFsPathargument inimportSnapshot/exportSnapshot. If theHasFSinstance is provided, theFsPathpath is interpreted as a path in the corresponding filesystem, and the snapshot is always copied. If theHasFSinstance is not provided, theFsPathpath is interpreted as a path in the filesystem for the database session, and the snapshot is hard linked with a fallback to copying.importSnapshotIO/exportSnapshotIOfunctions toDatabase.LSMTree, which accept aFilePathargument and always copy the snapshot files.importSnapshot/exportSnapshotfunctions toDatabase.LSMTree.Simple, which in turn call theimportSnapshotIO/exportSnapshotIOfunctions and correctly repackage any exceptions.SnapshotExportDirExistsErrorwould contain the internal snapshot path.