Goutham Veeramachaneni
3dbb400bef
Initial implementation of Delete on DB.
...
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
2017-05-20 00:35:50 +05:30
Fabian Reinartz
debfe9b1e5
Simplify AddFast and avoid errgroup Commits in general
2017-05-18 17:17:56 +02:00
Fabian Reinartz
fb5c5535fc
Misc cleanup
2017-05-18 16:38:45 +02:00
Fabian Reinartz
39df7e2bba
Switch blocks to ULID directories, drop sequenc numbers
2017-05-18 16:09:30 +02:00
Fabian Reinartz
285bc07030
Switch append refs to string
2017-05-18 10:56:57 +02:00
Fabian Reinartz
8b51b7e2be
Make WAL for HeadBlock composeable.
2017-05-13 18:14:18 +02:00
Fabian Reinartz
5534e6c53c
Make HeadBlock impl public, make interface private
2017-05-12 16:34:41 +02:00
Fabian Reinartz
44769c1654
Allow disabling lock file
2017-05-09 12:52:47 +02:00
Fabian Reinartz
35b62f001e
Change offset table layout, add TOC, ...
2017-04-30 10:18:07 +02:00
Fabian Reinartz
54a7b98cff
Fix and test ref handling in DB appender
2017-04-28 15:24:28 +02:00
Brian Brazil
d04bd947ea
Merge pull request #51 from prometheus/rollback
...
Make rollback actually rollback.
2017-04-19 11:29:03 +01:00
Brian Brazil
dba222b53c
Make rollback actually rollback.
...
Also add tests for basic commit/rollback
functionality.
Fixes #39
2017-04-19 11:28:36 +01:00
Fabian Reinartz
46c947d94f
Merge pull request #45 from mattbostock/document_appender_not_goroutine_safe
...
db: Add comment: Appender not goroutine safe
2017-04-17 12:12:20 +02:00
Matt Bostock
4d5ca4b9c1
db: Fix typo: reference
2017-04-14 22:02:06 +01:00
Matt Bostock
3dd5a4ee09
db: Add comment: Appender not goroutine safe
2017-04-14 21:39:08 +01:00
Fabian Reinartz
778103b450
Add liecence file and headers
2017-04-10 20:59:45 +02:00
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
Fabian Reinartz
c20cc44b06
Add docs, write sequence number to meta.json
2017-01-29 08:11:47 +01:00
Fabian Reinartz
30d8866c13
Limit compaction range, make cut and compact concurrent
2017-01-20 07:58:19 +01:00
Fabian Reinartz
67d185ceb9
Compact based on compaction generation
2017-01-19 19:45:52 +01:00
Fabian Reinartz
d4779b374c
Properly track and write meta file
2017-01-19 14:01:38 +01:00
Fabian Reinartz
9ddbd64d00
Move stats into meta.json file, cleanup, docs
2017-01-19 11:22:47 +01:00
Fabian Reinartz
e006bc6dc6
Improve error messages, create regular dir for block
2017-01-19 08:40:15 +01:00
Fabian Reinartz
d2322f6095
Improve compaction processing
2017-01-18 06:18:32 +01:00
Fabian Reinartz
343dd9d94c
Fix wrong byte size in WAL base ref
2017-01-17 08:40:31 +01:00
Fabian Reinartz
dd0b69fe1b
Export ErrNotFound
2017-01-16 14:18:32 +01:00
Fabian Reinartz
1c80c33e72
Fix bug of unsorted postings lists being created
...
The former approach created unordered postings list by either
map iteration of new series being unsorted (fixable) or concurrent
writers creating new series interleaved.
We switch back to generating ephemeral references for a single batch.
Newly created series have to be re-set upon the next insert.
2017-01-13 16:22:20 +01:00
Fabian Reinartz
c7f5590a71
Ensure order of postings when adding new series
2017-01-13 15:25:11 +01:00
Fabian Reinartz
d970f0256a
Add Rollback() and docs to Appender interface
2017-01-12 20:17:49 +01:00
Fabian Reinartz
22db9c3413
Remove old appendBatch methods
2017-01-12 20:04:49 +01:00
Fabian Reinartz
a317f252b9
Expose series references to clients
...
This exposes a reference number of a series represented by a label set
to clients.
Subsequent samples can be directly added via the reference rather than
repeatedly passing in the full labels. This drasitcally speeds up the
append process.
The appender chain uses different sections of the reference number for
assignment to child appenders and invalidating reference numbers as
necessary.
Clients can either pass out reference numbers themselves or have their
own optimized lookup, i.e. by directly associating unparsed metric
descriptors strings with reference numbers.
2017-01-12 20:00:54 +01:00
Fabian Reinartz
c32a94d409
Unexport HeadBlock, export Block interface
2017-01-10 15:41:57 +01:00
Fabian Reinartz
29883a18fc
Add own Appender() method for DB
2017-01-09 22:54:08 +01:00
Fabian Reinartz
142c89b8b0
Fix/update metrics
2017-01-09 19:14:21 +01:00
Fabian Reinartz
8c31c6e934
Make concurrent head chunk reads safe, fix misc races
...
This adds a 4 sample buffer to every head chunk. The XOR
compression scheme may edit bytes in place. The minimum size
of a sample is 2 bits. So keeping the last 4 samples in an in-memory
buffer makes it safe to query the preceeding ones while samples
are added
2017-01-09 16:51:39 +01:00
Fabian Reinartz
1943f8d1bb
Fix head block stats races
2017-01-07 18:02:17 +01:00
Fabian Reinartz
300f4e2abf
Use separate lock for series creation
...
This uses the head block's own lock to only lock if new series were
encountered.
In the general append case we just need to hold a
2017-01-06 18:10:50 +01:00
Fabian Reinartz
63e12807da
Don't update head postings mapper on every append
2017-01-06 16:43:18 +01:00
Fabian Reinartz
71efd2e08d
Periodically fsync WAL, make head cut async
2017-01-06 15:18:06 +01:00
Fabian Reinartz
2eb544c98e
Change file names and maker parsing safer
2017-01-06 13:13:22 +01:00
Fabian Reinartz
96c2bd249f
Handle compaction trigger and reinitializing in DB
2017-01-06 13:03:23 +01:00
Fabian Reinartz
3ed2c2a14b
Rename Partition to regular DB, DB to PartitionedDB
2017-01-06 11:40:09 +01:00
Fabian Reinartz
937cdb579c
Switch to sequential block names
...
This changes block directory names from the int64 timestamp
to sequential numbering.
2017-01-06 10:45:03 +01:00
Fabian Reinartz
4590b61343
Rename shard to partition
2017-01-06 08:08:02 +01:00
Fabian Reinartz
5aa7f7cce8
Compact head block into persisted block
2017-01-04 21:11:15 +01:00
Fabian Reinartz
3f72d5d027
Fix last timestamp initialization
...
This initializes the chunkDesc's last timestamp to the minimum
value so initial samples with a timestamp of 0 (e.g. in tests)
are not accidentally dropped.
2017-01-04 14:06:40 +01:00
Fabian Reinartz
ec99f99d3d
Fix and test bug in shardSeriesSet
2017-01-03 19:02:42 +01:00
Fabian Reinartz
ac49f8c15e
Consolidate persistence and compaction
2017-01-03 16:49:37 +01:00
Fabian Reinartz
91b65b55e7
Run persistence in separate goroutine
2017-01-02 22:24:35 +01:00
Fabian Reinartz
a648ef5252
Convert persister into function
2017-01-02 16:58:47 +01:00
Fabian Reinartz
dbd2b21d2e
Make persistence atomic
2017-01-02 14:41:13 +01:00
Fabian Reinartz
62b8ded0a5
Rename iterator value getters to At()
2017-01-02 13:33:06 +01:00
Fabian Reinartz
5d75a3dc7b
Add basic compaction
...
This adds a basic compactor that will merge two persisted blocks into
one. It simply fully rewrites the index and concatenates the chunk
lists.
It just writes into the current working dir and doesn't properly handle
which blocks to compact for now.
2017-01-02 10:34:55 +01:00
Fabian Reinartz
c00d17e691
Modify IndexReader API to accomodate compaction
...
This changes the IndexReader API to expose plain labels
and chunk meta information instead of a Series interface.
Dropping of irrelevant chunks is moved into the querier.
A LabelIndices method is added to query for existing label
value indices.
2016-12-31 16:24:04 +01:00
Fabian Reinartz
1e1a37b15b
Remove double-reference in chunk hashmap
2016-12-31 10:19:02 +01:00
Fabian Reinartz
675f0886f0
Append to chunks cannot error
2016-12-31 10:10:27 +01:00
Fabian Reinartz
7280533c42
Add basic shard metrics
2016-12-31 09:48:49 +01:00
Fabian Reinartz
a009247ab7
Add matching of empty label
2016-12-30 19:36:28 +01:00
Fabian Reinartz
eb4f366988
Add return error to Appender.Add
2016-12-29 11:03:39 +01:00
Fabian Reinartz
3a5468f251
Lock shards during querying and shutdown
2016-12-28 11:41:44 +01:00
Fabian Reinartz
ab7fbc05ad
Zero timestamp as base, use binary search list postings
2016-12-28 08:50:20 +01:00
Fabian Reinartz
f8111cef0e
Fix chunk series iterator seeking
2016-12-26 16:55:44 +01:00
Fabian Reinartz
787199a88e
Fix erroneous value assignments
2016-12-22 20:57:00 +01:00
Fabian Reinartz
8aba95048a
Rename to OpenHeadBlock
2016-12-22 20:00:24 +01:00
Fabian Reinartz
9c6a72aadd
Load head with WALs correctly
2016-12-22 15:54:39 +01:00
Fabian Reinartz
1dde3b6d31
Add WAL decoder+loading and benchmarks
2016-12-22 15:18:33 +01:00
Fabian Reinartz
0b8c77361e
Add initial WAL writing
2016-12-22 12:05:24 +01:00
Fabian Reinartz
2a825f6c28
Consolidate mem index into HeadBlock
2016-12-22 01:12:28 +01:00
Fabian Reinartz
da2beb3e6d
Fix zero division, add buffer series iterator
2016-12-21 13:04:51 +01:00
Fabian Reinartz
ede733ab6c
Extract labels package
2016-12-21 09:39:01 +01:00
Fabian Reinartz
ee217adc7e
Redfine append interface, remove old Prometheus storage from bench
2016-12-21 00:02:37 +01:00
Fabian Reinartz
d9ca4b47f5
Fix offset errors, fix persisted postings order
2016-12-20 13:14:55 +01:00
Fabian Reinartz
1b23d62e3f
Properly close files before reopening
2016-12-19 22:37:03 +01:00
Fabian Reinartz
00a503129b
Use contextualized and traced errors in reader
2016-12-19 22:29:49 +01:00
Fabian Reinartz
bad93d8d57
Extract head serialization into Head method
2016-12-18 14:43:27 +01:00
Fabian Reinartz
b08f82fa4e
Pre-select relevant chunks on series access.
...
This adds interval metadata to indexed chunks. The queried interval
is used to filter chunks when queried from the index to save
unnecessary accesses of the chunks file.
This is especially relevant for series that come and go often and larger
files.
2016-12-16 12:13:17 +01:00
Fabian Reinartz
bd77103a49
Add stats serialization, load querier of all blocks
2016-12-15 16:14:33 +01:00
Fabian Reinartz
b2f1db5666
Add unsafe string and slice conversions
2016-12-15 11:56:41 +01:00
Fabian Reinartz
5424a0cf75
Rename SeriesShard to Shard
2016-12-15 08:36:09 +01:00
Fabian Reinartz
9873e18b75
Add loading of persisted blocks
2016-12-15 08:36:07 +01:00
Fabian Reinartz
ca89080128
Misc fixes for initial Prometheus integration
2016-12-14 18:38:46 +01:00
Fabian Reinartz
fc992fafc2
Change querier interface, initial implementations
2016-12-14 15:39:23 +01:00
Fabian Reinartz
6eeb0ef01c
Add queriers and partial mocks
2016-12-13 15:26:58 +01:00
Fabian Reinartz
5e02e28f9c
Add proper mmap calls
2016-12-11 15:49:36 +01:00
Fabian Reinartz
14dbc59f2b
cleanup and switching removal of unsafe calls.
2016-12-10 18:09:57 +01:00
Fabian Reinartz
3a528c3078
Write plain postings list index
2016-12-10 09:44:00 +01:00
Fabian Reinartz
8cbc95c316
Write label value indices
2016-12-09 21:40:38 +01:00
Fabian Reinartz
1e0edf367b
Write index with symbol table
2016-12-09 21:23:34 +01:00
Fabian Reinartz
40a451694f
Refactor persistence into interfaces
2016-12-09 20:45:46 +01:00
Fabian Reinartz
62f9dc311c
misc
2016-12-09 16:54:38 +01:00
Fabian Reinartz
74f8dfd95d
Persist blocks periodically
2016-12-09 13:41:38 +01:00
Fabian Reinartz
0cf8bb9e53
Move sub-indexes into single index structure
2016-12-09 10:41:51 +01:00
Fabian Reinartz
8aa99a3ebd
misc
2016-12-09 10:00:14 +01:00
Fabian Reinartz
2c34a15fe6
Add initial seriailization of block data
2016-12-08 17:43:10 +01:00
Fabian Reinartz
3ef7da33c8
Restructure files
2016-12-08 12:21:03 +01:00
Fabian Reinartz
b845f8d3a1
Reduce test data allocations
2016-12-08 11:59:54 +01:00
Fabian Reinartz
52276c6966
Bucket samples before appending.
...
This pre-sorts samples into buckets before appending them to reduce
locking of shards.
2016-12-07 17:10:49 +01:00
Fabian Reinartz
9b459458d0
Docs and interface definitions
2016-12-05 21:26:19 +01:00
Fabian Reinartz
83574b1565
Add new interfaces and skeleton
2016-12-04 13:16:11 +01:00
Fabian Reinartz
6f93a699e6
wipe
2016-12-02 17:49:05 +01:00
Fabian Reinartz
f9f11c4a08
Add main db implementation
2016-11-15 10:34:25 +01:00