diff --git a/setup.cfg b/setup.cfg index 86e9c08c185b6dd490131cb1c3eefcb2a7465580..6a7da98776da7ae092ff61398baa0bad7bab7f44 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ # coding: utf-8 [metadata] name = tempsdb -version = 0.6a5 +version = 0.6 long-description = file: README.md long-description-content-type = text/markdown; charset=UTF-8 license_files = LICENSE diff --git a/tempsdb/chunks/base.pyx b/tempsdb/chunks/base.pyx index ff5eed7e17a466ac4c2782ea48542d3d03e35ba7..5c5aad8ed82be9f95e9cda8527dd06072b202233 100644 --- a/tempsdb/chunks/base.pyx +++ b/tempsdb/chunks/base.pyx @@ -7,7 +7,7 @@ import mmap import warnings from .gzip cimport ReadWriteGzipFile -from ..exceptions import Corruption, InvalidState, AlreadyExists, StillOpen +from ..exceptions import Corruption, StillOpen from ..series cimport TimeSeries @@ -167,12 +167,6 @@ cdef class Chunk: self.pointer = self.entries*(self.block_size+TIMESTAMP_SIZE)+HEADER_SIZE self.max_ts = self.get_timestamp_at(self.entries-1) - print('Readed',self.path, 'entries=', self.entries, 'max ts=', self.max_ts, - 'file size=', self.file_size, 'pointer=', self.pointer, 'page size=', self.page_size) - - if self.entries == 3867: - print('last record of 3867: ', repr(self.mmap[69592:69610])) - if self.pointer >= self.page_size: # Inform the OS that we don't need the header anymore self.mmap.madvise(mmap.MADV_DONTNEED, 0, HEADER_SIZE+TIMESTAMP_SIZE) @@ -274,7 +268,6 @@ cdef class Chunk: cdef: unsigned long starting_index = HEADER_SIZE + index * (self.block_size + TIMESTAMP_SIZE) unsigned long stopping_index = starting_index + TIMESTAMP_SIZE - print('reading timestamp from', starting_index, 'to', stopping_index) return STRUCT_Q.unpack(self.mmap[starting_index:stopping_index])[0] cpdef unsigned int find_left(self, unsigned long long timestamp): @@ -434,7 +427,6 @@ cdef class Chunk: self.sync() self.mmap.close() self.file.close() - print('closing', self.path) return 0 def __del__(self) -> None: diff --git a/tempsdb/chunks/normal.pyx b/tempsdb/chunks/normal.pyx index 245b6f19b10de41c82839a57cf0bcc9130852644..fb20b11ab43c686d86948c1db9ff80c3ef8fd727 100644 --- a/tempsdb/chunks/normal.pyx +++ b/tempsdb/chunks/normal.pyx @@ -41,12 +41,12 @@ cdef class NormalChunk(Chunk): if self.file_lock_object: self.file_lock_object.acquire() try: - self.sync() self.file_size += self.page_size self.file.seek(0, io.SEEK_END) ba = bytearray(self.page_size) ba[-FOOTER_SIZE:] = STRUCT_L.pack(self.entries) self.file.write(ba) + self.file.flush() try: self.mmap.resize(self.file_size) except OSError as e: @@ -54,6 +54,7 @@ cdef class NormalChunk(Chunk): self.switch_to_descriptor_based_access() else: raise + self.sync() finally: if self.file_lock_object: self.file_lock_object.release() @@ -78,12 +79,10 @@ cdef class NormalChunk(Chunk): if self.closed: raise InvalidState('chunk is closed') - if self.pointer >= self.file_size-FOOTER_SIZE-self.block_size-TIMESTAMP_SIZE: + if self.pointer > self.file_size-FOOTER_SIZE-self.block_size-TIMESTAMP_SIZE: self.extend() cdef unsigned long long ptr_end = self.pointer + TIMESTAMP_SIZE # Append entry - if self.entries > 4090: - print('writing %s to %s@%s ec=%s' % (repr(data), self.path, self.pointer, self.entries)) self.mmap[self.pointer:ptr_end] = STRUCT_Q.pack(timestamp) self.mmap[ptr_end:ptr_end+self.block_size] = data self.entries += 1 diff --git a/tests/test_series.py b/tests/test_series.py index 48c50720ce55f27d59004accbe4a34f40645dca0..740c1a0e8276d571a46d9c9bf66fd624fba05d4f 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -4,7 +4,6 @@ import unittest class TestSeries(unittest.TestCase): - @unittest.skip('bug') def test_write_series_append_after_close(self): from tempsdb.series import create_series, TimeSeries series = create_series('test6', 'test6', 10, 4096) @@ -26,7 +25,6 @@ class TestSeries(unittest.TestCase): series.close() - @unittest.skip('because of reasons') def test_write_series_with_interim_close(self): from tempsdb.series import create_series, TimeSeries series = create_series('test4', 'test4', 10, 4096)