diff --git a/README.md b/README.md index 14b92b3dc3e8113bd39649063faccdb554e9ef2b..e2ffc1e4d24e82aba6b1049196c1168fc918cb50 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Then copy your resulting wheel and install it via pip on the target system. * older TempsDB databases that do not support varlens will be updated upon opening * added metadata support for databases +* a flush will be done before re-enabling mmap ## v0.5.3 diff --git a/setup.py b/setup.py index df8396fcbc05b6f5982981b490db345323585c26..dc63bba1de03823a3baf2b581f75b9e72b89a5dd 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ ext_modules = build([Multibuild('tempsdb', find_pyx('tempsdb'), **cythonize_kwargs) setup(name='tempsdb', - version='0.5.4a3', + version='0.5.4a4', packages=find_packages(include=['tempsdb', 'tempsdb.*']), install_requires=['satella>=2.14.24', 'ujson'], ext_modules=ext_modules, diff --git a/tempsdb/chunks/base.pyx b/tempsdb/chunks/base.pyx index c856b1dcfca897526d387391ec9d08090877268e..222f7b0c8f189bc6da75cf7167b49072c6076308 100644 --- a/tempsdb/chunks/base.pyx +++ b/tempsdb/chunks/base.pyx @@ -124,6 +124,7 @@ cdef class Chunk: :raises Corruption: unable to mmap file due to an unrecoverable error """ if isinstance(self.mmap, AlternativeMMap): + self.mmap.flush() try: self.mmap = mmap.mmap(self.file.fileno(), 0) self.file_lock_object = None diff --git a/tempsdb/chunks/direct.pxd b/tempsdb/chunks/direct.pxd index ddee23ac118c52441b2959382f25393efe8a02d3..38214db13ca3502169c268f7cece3fbdaede8b96 100644 --- a/tempsdb/chunks/direct.pxd +++ b/tempsdb/chunks/direct.pxd @@ -8,3 +8,4 @@ cdef class DirectChunk(Chunk): cpdef object open_file(self, str path) cpdef int after_init(self) except -1 cpdef int append(self, unsigned long long timestamp, bytes data) except -1 + cpdef int switch_to_mmap_based_access(self) except -1 diff --git a/tempsdb/chunks/direct.pyx b/tempsdb/chunks/direct.pyx index 4f23a977fa01255a88829c231825a8aa44c140be..af811cfe6173ece2a7974a8d9c3fcffc5609939d 100644 --- a/tempsdb/chunks/direct.pyx +++ b/tempsdb/chunks/direct.pyx @@ -80,6 +80,12 @@ cdef class DirectChunk(Chunk): self.max_ts, = STRUCT_Q.unpack(b) return 0 + cpdef int switch_to_mmap_based_access(self) except -1: + if self.gzip: + raise RuntimeError('Cannot switch to mmap because its gzipped!') + super().switch_to_mmap_based_access() + return 0 + cpdef int append(self, unsigned long long timestamp, bytes data) except -1: cdef bytes b if self.file_lock_object: