Skip to content
Snippets Groups Projects
Commit 3a982114 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

flush() before reenabling mmap

parent af06953a
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,7 @@ Then copy your resulting wheel and install it via pip on the target system. ...@@ -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 * older TempsDB databases that do not support varlens will be updated upon opening
* added metadata support for databases * added metadata support for databases
* a flush will be done before re-enabling mmap
## v0.5.3 ## v0.5.3
......
...@@ -42,7 +42,7 @@ ext_modules = build([Multibuild('tempsdb', find_pyx('tempsdb'), ...@@ -42,7 +42,7 @@ ext_modules = build([Multibuild('tempsdb', find_pyx('tempsdb'),
**cythonize_kwargs) **cythonize_kwargs)
setup(name='tempsdb', setup(name='tempsdb',
version='0.5.4a3', version='0.5.4a4',
packages=find_packages(include=['tempsdb', 'tempsdb.*']), packages=find_packages(include=['tempsdb', 'tempsdb.*']),
install_requires=['satella>=2.14.24', 'ujson'], install_requires=['satella>=2.14.24', 'ujson'],
ext_modules=ext_modules, ext_modules=ext_modules,
......
...@@ -124,6 +124,7 @@ cdef class Chunk: ...@@ -124,6 +124,7 @@ cdef class Chunk:
:raises Corruption: unable to mmap file due to an unrecoverable error :raises Corruption: unable to mmap file due to an unrecoverable error
""" """
if isinstance(self.mmap, AlternativeMMap): if isinstance(self.mmap, AlternativeMMap):
self.mmap.flush()
try: try:
self.mmap = mmap.mmap(self.file.fileno(), 0) self.mmap = mmap.mmap(self.file.fileno(), 0)
self.file_lock_object = None self.file_lock_object = None
......
...@@ -8,3 +8,4 @@ cdef class DirectChunk(Chunk): ...@@ -8,3 +8,4 @@ cdef class DirectChunk(Chunk):
cpdef object open_file(self, str path) cpdef object open_file(self, str path)
cpdef int after_init(self) except -1 cpdef int after_init(self) except -1
cpdef int append(self, unsigned long long timestamp, bytes data) except -1 cpdef int append(self, unsigned long long timestamp, bytes data) except -1
cpdef int switch_to_mmap_based_access(self) except -1
...@@ -80,6 +80,12 @@ cdef class DirectChunk(Chunk): ...@@ -80,6 +80,12 @@ cdef class DirectChunk(Chunk):
self.max_ts, = STRUCT_Q.unpack(b) self.max_ts, = STRUCT_Q.unpack(b)
return 0 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: cpdef int append(self, unsigned long long timestamp, bytes data) except -1:
cdef bytes b cdef bytes b
if self.file_lock_object: if self.file_lock_object:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment