Commit graph

134 commits

Author SHA1 Message Date
Fabian Reinartz 10c7c9acbe Adjust import names to new repository organisation 2017-04-04 11:27:26 +02:00
Fabian Reinartz 767b88a3a5 Parallelize commits to prevent deadlocks
This parallelizes commits to prevent deadlocks across inconsistently
locked heads. As commits are currently not fully atomic across
heads, this does decrease our guarantees.
2017-04-04 11:21:19 +02:00
Fabian Reinartz a52980e0a8 Add workaround for deadlocks
This adds a workaround to avoid deadlocks for inconsistent write lock
order across headBlocks.
Things keep working if transactions only append data for the same
timestamp, which is generally the case for Prometheus.

Full behavior should be restored in a subsequent change.
2017-03-27 19:05:34 +02:00
Fabian Reinartz e478d0e3bc Actually close olds blocks in reloadBlocks
This fixes a bug leaking memory because blocks were not actually closed
as the closing call references the initial, empty slice
2017-03-23 18:27:20 +01:00
Fabian Reinartz 70909ca8ad Ensure GC runs after each compactor call
GC is triggered rarely, which may cause unnecessarily high memory
spikes when running several compaction cycles in a row. Explicitly run
GC so we don't have idle bytes marked as used from the previous cycle.
2017-03-21 12:21:02 +01:00
Fabian Reinartz 55ee4b5b3b Merge branch 'master' of github.com:fabxc/tsdb 2017-03-21 10:11:39 +01:00
Fabian Reinartz c18e055d7c Fix races and add comments on remaining ones 2017-03-21 10:11:23 +01:00
Fabian Reinartz e837034360 Merge pull request #14 from Gouthamve/log-update
Update kit/log To New API
2017-03-21 09:56:32 +01:00
Fabian Reinartz 9c93f8f2aa Fix various races
This fixes different race condition encoutnered when running Prometheus.
It reduces the overall performance in the synthetic benchmark a fair bit
but has no indiciations of impacting a real-world setup notably.
2017-03-20 14:45:27 +01:00
Fabian Reinartz 3635569257 Trigger reload correctly on interrupted compaction 2017-03-20 10:41:43 +01:00
Fabian Reinartz 2c999836fb Add Queryable interface to Block
This adds the Queryable interface to the Block interface. Head and
persisted blocks now implement their own Querier() method and thus
isolate customization (e.g. remapPostings) more cleanly.
2017-03-20 10:21:21 +01:00
Fabian Reinartz 11be2cc585 Add composed Block interfaces, remove head generation
This adds more lower-leve interfaces which are used to compose
to different Block interfaces.
The DB only uses interfaces instead of explicit persistedBlock and
headBlock. The headBlock generation property is dropped as the use-case
can be implemented using block sequence numbers.
2017-03-20 09:02:36 +01:00
Goutham Veeramachaneni df7db4ac07
Update kit/log To New API
NewContext has been removed couple of weeks back.
Ref: https://github.com/go-kit/kit/releases/tag/v0.4.0
2017-03-19 21:03:09 +05:30
Fabian Reinartz 303a4ec3bc Sync directory on retention delation 2017-03-19 13:50:35 +01:00
Fabian Reinartz 863d38dfee Fix unreturned lock 2017-03-17 15:56:19 +01:00
Fabian Reinartz d0770302ed Add retention deletion 2017-03-17 15:30:05 +01:00
Fabian Reinartz 4962175218 Fix deadlock between heads and headmtx
With hundreds of concurrent appenders the locking order between the
headBlocks on instantiating appenders and write locking the headmtx
is hard to impossible to get consistent.
Just never instantiate appenders while holding the headmtx lock in any
way.
2017-03-17 14:10:18 +01:00
Fabian Reinartz 65b846ae5b Remove unreturned locks, detect writes on closed heads 2017-03-17 12:12:50 +01:00
Fabian Reinartz 32c32013a6 Fix loading of persisted blocks 2017-03-09 15:40:13 +01:00
Fabian Reinartz cb4dde7659 Fix WAL log recovery bug
This fixes a bug where the last WAL file was closed after consuming it
instead of being left open for further writes.
Reloading of blocks on startup considers loading head blocks now.
2017-03-08 16:53:07 +01:00
Fabian Reinartz 3910b913bd Revert interval overlap comparison changes 2017-03-07 12:01:25 +01:00
Fabian Reinartz 87805fb83f Remove Partitioned* code 2017-03-06 17:34:49 +01:00
Fabian Reinartz eedbebe1d7 Misc cleanups 2017-03-06 14:34:49 +01:00
Fabian Reinartz 50791a412e Remove leaky Appender abstraction for hashedAppend 2017-03-06 14:27:33 +01:00
Fabian Reinartz 87d270fe11 Fix interval check, make DB shutdown concurrent 2017-03-06 12:13:15 +01:00
Fabian Reinartz 04783831e2 Correctly close compacted blocks. 2017-03-06 09:33:55 +01:00
Fabian Reinartz 55a9b5428a Add separate head mutex
Introduce a seperate mutex for the head blocks to avoid a race where
a post-compaction reload may run between switching the DB's base mutex
to create a new head block in an appender.
2017-03-04 17:41:01 +01:00
Fabian Reinartz 3e569bc964 Optimize memory allocations in writer 2017-03-02 23:35:02 +01:00
Fabian Reinartz ffb24a98f4 Add missing unlock, run debug endpoint in benchmark 2017-03-02 21:54:02 +01:00
Fabian Reinartz 92120448c2 Properly cleanup compacted dirs, fixes, docs 2017-03-02 14:32:09 +01:00
Fabian Reinartz 2c3e778d90 Compactor interface 2017-03-02 09:17:30 +01:00
Fabian Reinartz 2c3b56350a Write meta.json file atomically 2017-03-01 17:19:57 +01:00
Fabian Reinartz 6c4217276f Periodically trigger compaction
This addresses an issue where the compaction triggered on cutting
a new block doesn't find anything as the writers are still active on the
block that should be ready for compaction.
2017-03-01 16:52:21 +01:00
Fabian Reinartz db5c88ea9a Misc compaction fixes 2017-02-28 08:40:51 +01:00
Fabian Reinartz b281e4e39b Accept prometheus.Registerer in constructor 2017-02-28 07:26:24 +01:00
Fabian Reinartz 306831f151 Add per-block state ULID 2017-02-27 10:46:15 +01:00
Fabian Reinartz 78780cd2ba Segment chunk file
This adds write path support for segmented chunk data files.
Files of 512MB are pre-allocated and written to. If the file size
is exceeded, the next file is started. On completion, files
are truncated to their final size.
2017-02-23 10:50:22 +01:00
Fabian Reinartz a3b47c4929 Create default logger for DB 2017-02-19 16:04:37 +01:00
Fabian Reinartz f734773214 Replace per-file locking with single PID lock file
File locks have a multitude of problems that make them hard to use
correctly. As they are just advisory, they are only meaningful to
prevent accidents like running the same process twice.
A simple PID file lock works reliably in those cases and is simpler.
2017-02-19 13:01:19 +01:00
Fabian Reinartz 79944a5912 Break out WAL into segment files 2017-02-13 23:53:19 -08:00
Fabian Reinartz 987a90d149 Don't delete files if retention duration is 0 2017-02-11 11:49:17 -08:00
Fabian Reinartz 9c76624df2 Add initial retention cutoff 2017-02-09 17:54:26 -08:00
Fabian Reinartz f1435f2e2c Track appended samples properly in metric 2017-02-08 16:13:16 -08:00
Fabian Reinartz 012cf4ef25 Count writer references on head blocks 2017-02-04 11:53:52 +01:00
Fabian Reinartz 5a1c8eaa0e Fix missing appends after reference lookups 2017-02-02 11:10:17 +01:00
Fabian Reinartz f556036037 Close blocks before overwriting with compacted one
This prevents the meta.json file of a compacted block
to be overwritten with data of the old block.
2017-02-02 09:32:06 +01:00
Fabian Reinartz ac5229e1b4 Correctly write empty blocks and extend appenders by new blocks 2017-02-02 07:58:54 +01:00
Fabian Reinartz 42fa342229 Improve multi-head handling
This improves handling of multiple head blocks. Configuration is
simplified to specify the number of concurrently appendable blocks.
2017-02-01 21:35:21 +01:00
Fabian Reinartz 30efe4a58c Support writing to multiple head blocks
This is an initial (and hacky) first pass on allowing
appending to multiple blocks simultaniously to avoid
dropping samples right after cutting a new head block.
It's also required for cases like the PGW, where a scrape may
contain varying timestamps.
2017-02-01 15:57:28 +01:00
Fabian Reinartz a61a31a5d7 compaction: add fast-path for compacting mem blocks 2017-01-30 09:49:36 +01:00