Commit graph

93 commits

Author SHA1 Message Date
Fletcher Haynes
da9b57bd45 Updated dependency paths to reflect new repo location 2022-09-06 09:39:22 -07:00
Fletcher Haynes
eb06bb50ae Updated code to latest version for open-sourcing. 2022-09-02 13:23:39 -07:00
Seebs
e5ffed35a4 use labeled targets for break statements
break in a select in a for terminates the current case of the
select, but does not terminate the for loop. The worker queue
implementations for opening indexes/fields/views all suffered
from the same issue here.

Also fix a `<= 0` on a uint value.

All hail staticcheck.
2019-10-11 14:44:25 -05:00
Ben Johnson
c7c9c1e1d7
v2.0.0
Co-authored-by: Cody Soyland <codysoyland@gmail.com>
2019-10-08 14:56:17 -06:00
Seebs
2d9ca0888f Use work queue for opening/closing fragments
When starting up, we can have a large number of views, each
with some number of fragments, and by default these were being
opened sequentially. There's no real benefit to that; they're
all nicely independent from each other and don't need much
locking, so we implement a trivial semaphore and launch the
operations asynchronously. We also combine them into
errgroups.

Similarly, we do this for fields and views, capping the number
of fields (or views) opened in parallel to avoid hitting a
system-wide limit on threads created (oops). Note that the
limits are shared, not multiplicative; we cap this fairly
arbitrarily at 8 fields being opened, and 16 views being opened,
at a time, but NumCPU*2 fragments being opened by those views.

This dramatically increases CPU load during startup, but doesn't
seem to significantly increase total CPU time, it just scales
much better on machines with lots of cores.
2019-07-25 16:03:24 -05:00
Seebs
4b657c1962
use a queue for snapshot operations
As the size of a fragment grows, the cost of snapshots
increases; with a large fragment getting a lot of large writes,
every write will trigger a snapshot, while any other writes have
to wait for that snapshot before they, too, can trigger a snapshot.

To address this, we introduce a background queue of snapshots.
In general, operations which were omitting their ops log writes
and just snapshotting no longer do; they emit an ops log. This does
mean that, in some cases, the ops log is written and then a snapshot
takes place essentially immediately, which costs us some performance.
However, that only actually happens under very light load; under
heavier load, there's generally going to be multiple writes coalesced
into each snapshot, and the ops log writes for them will be much
cheaper than a full snapshot.
2019-07-01 13:16:02 -05:00
Seebs
b369dace69
remap storage on reopen, instead of remarshalling it
When we do a snapshot, we may end up with containers which are
mmapped to the old file, and containers which have allocated storage
identical to the contents of the new file. It would be nicer if they
were mapped to it. But unmarshalling the entire file is expensive.

Instead, we remap it. (Or, if we couldn't mmap it, just make sure
the old stuff is no longer using the old storage space before we
munmap it.)
2019-07-01 13:16:02 -05:00
Seebs
b2fb51be1f view.deleteFragment should hold the lock while altering fragments
If you delete a fragment while something else is calling allFragments,
you can cause a race. This almost never happens in practice, because
deleting fragments is rare, and the only likely overlap would be with
something like the holder cache flush, which only happens once a
minute. But if you slowed down the rest of the tests enough, and ran
with -race, you might see it.

We check v.fragments directly instead of calling v.Fragment, because
v.Fragment also needs a lock, and we don't want to drop the lock between
the check for existence and the delete operation.
2019-06-26 16:14:37 -05:00
Cody Soyland
9fb6d84d80 Remove extraneous stat tags to improve prometheus performance 2019-06-10 08:18:30 -05:00
Seebs
388efd0e73 use os.Rename semantically correctly
So it's true that Rename's arguments are called oldname/newname, and
you want to rename from the previous name to the new name.

And it's true that we're calling Rename on oldPath and newPath.

But in our case, oldPath is the name the fragment file had before
the operation, and newPath is the name of the temporary file
created during the operation. Use tmpPath and frag.path to make
the semantics clearer.
2019-06-04 10:00:16 -05:00
Ben Johnson
7ed9fba335
Unbounded BSI w/ sign magnitude
This commit implements BSI with variable bit depth using a
sign magnitudeto indicate whether a value is positive or negative.
This also rearranges the existence bit to be the first bit instead
of the last bit.
2019-05-17 15:52:17 -06:00
Travis Turner
875c95b2c3
add more Debugf() statements to the holder open process 2019-04-30 15:16:10 -05:00
Matt Jaffee
3a07abdeae
remove shard validation stuff
it seems to have a bug where there is some race on cluster startup
which can cause it to think that the node doesn't own any shards.
2019-04-22 17:36:40 -05:00
Seebs
77d49ded64 so much lint
So with the switch to a new linter, we get a lot of new warnings,
and the majority of them are harmless probably, but a few might be
real. Variously just use _ to suppress warnings, or report errors.
There's probably things here that deserve better fixes, but we can
always revisit it.
2019-04-16 12:07:18 -05:00
Todd Gruben
418a8788ed
gofmt missing 2019-03-20 22:04:20 -05:00
Todd Gruben
8edd2b3d13
applied travis suggestions 2019-03-20 22:04:20 -05:00
Todd Gruben
38de65eac0
only load shards that are applicable to node 2019-03-20 22:04:19 -05:00
Seebs
dde6954de4 view.go: deal with races in fragment creation
There existed a case where two goroutines would try to
CreateIfNotExists the same fragment, and the first would
create it, but not put it in the fragments table, then
drop the lock, try to broadcast a message, and if it
succeeded then populate the fragments table. The second
would come along during the broadcast, not find an
entry, try to create one, and fail because the file was
already locked.

Basic problem: At least one test in server/ will fail
if we don't delay to send out broadcast messages. Everything
will lock up if we can wait forever (or even just a very
long time) for the message broadcast. We don't ever want
to have an inconsistent state -- so we don't want to either
fail to get a fragment when one's been created, or get one
that's about to be deleted if the broadcast fails.

So, creation and stashing in the fragments table is
atomic and immediate. After that, we optimistically attempt
to broadcast. If we fail, we fail. We delay up to about
50ms for the broadcast to be done, but after that return
anyway. This way, if things are going well everything
works, and if there's unexpected delays, things work except
some nodes in a cluster may not know about available
shards on other nodes sometimes. But that would have
happened anyway. A proper fix is beyond the scope of this
patch.
2019-02-21 16:43:19 -06:00
Matt Jaffee
9d4a6e2be7
don't add the fragment and then remove it 2018-12-11 15:45:44 -06:00
Matt Jaffee
7304258967
improve comments 2018-12-11 15:45:44 -06:00
Matt Jaffee
4b786e1057
attempt to fix deadlock by releasing view lock before broadcasting CreateShard 2018-12-11 15:45:44 -06:00
Seebs
a203313143 move Logger and Stats to their own packages
I'd like to add stat tracking to Roaring, which means it
has to be able to import the stats package, which means
stats has to be a package rather than part of the pilosa
package. If stats stops being in pilosa, it still needs
a way to import logger, so logger also has to leave the
pilosa package. Then everything using them needs to import
them and use package selectors on their names.

This doesn't actually add the stats support to roaring,
it just makes it so there's a way to import the stats
code from something in the roaring package.
2018-11-15 15:10:44 -06:00
Travis Turner
dbe4197871
ensure view closes fragment on broadcast error 2018-10-01 11:22:35 -05:00
Travis Turner
4f17dbdbf1
add support for Bool fields
prevent import of non-boolean row values to bool fields
2018-09-21 09:25:41 -05:00
Ben Johnson
f4c9c0fed3
Maintain available shards set.
This commit removes the previous `MaxShard` tracking and replaces
it with an `Available Shards` set tracking. This allows sparse shard
tracking without implicitly tracking all shards in between.
2018-08-22 07:57:58 -06:00
Cody Soyland
e9523063b5 Fix linter issues: unused 2018-07-20 10:33:29 -05:00
Travis Turner
06f5d04f1c
swap out mapVector for rowsVector in mutex fields 2018-07-19 14:01:30 -05:00
Travis Turner
a07ed360ab
add mutex field type 2018-07-19 14:01:29 -05:00
Matt Jaffee
2cec75e399
add proto encoding subpackage and use for send and receive message 2018-07-05 12:00:42 -05:00
Matt Jaffee
cd8c63c125
tests passing 2018-07-04 21:43:18 -05:00
Matt Jaffee
2202bf467b
unexport view stuff 2018-07-02 17:18:00 -05:00
Matt Jaffee
cff01f46c2
unexport fragment.go stuff 2018-07-02 14:50:33 -05:00
Matt Jaffee
9ea300da20
unexport broadcaster 2018-07-02 08:34:58 -05:00
Matt Jaffee
6ff792c164
remove dead code (deadcode) 2018-06-29 08:12:04 -05:00
Travis Turner
e17096328d
Merge branch 'develop' into slice-to-shard 2018-06-28 15:38:40 -05:00
tgruben
a81e01b019
Merge branch 'develop' into clearbit-notime 2018-06-28 14:12:29 -05:00
Travis Turner
5dd7a9556a
rename slice to shard 2018-06-28 14:07:07 -05:00
Todd Gruben
fcecb871cf naming adjustments; code cleanup 2018-06-28 12:41:39 -05:00
Todd Gruben
4970083d4d refactored strategy for time based clearbit 2018-06-27 18:15:44 -05:00
Todd Gruben
35af580183 expanded views to contain viewType for special handling 2018-06-26 10:54:06 -05:00
Travis Turner
50794bf63b
move fieldOptions unmarshal to the handler
validate fieldOptions in http package
2018-06-25 15:14:22 -05:00
Matt Jaffee
56ed9bfbe1
remove broadcaster methods from gossip- don't use sendAsync anywhere 2018-06-18 18:47:29 -05:00
Travis Turner
7d91261968
un-export some package level constants 2018-06-13 17:18:52 -05:00
Travis Turner
fe167ea78c
un-export some top-level functions 2018-06-13 16:44:24 -05:00
Travis Turner
e58d407182
unexport (most) View methods 2018-06-07 22:50:49 -05:00
Travis Turner
173939813f
remove slice argment from Field.Row() method 2018-06-07 17:14:46 -05:00
Travis Turner
3c3c98371b
unexport Fragment.Row(). This required creating Field.Row() and View.row() 2018-06-07 15:09:58 -05:00
Travis Turner
468ad57b6d
un-export Fragment.SetBit and Fragment.ClearBit.
adds methods to test.Holder to set/clear bits on a field.
2018-06-07 13:43:20 -05:00
Travis Turner
15cb391570
first pass at un-exporting Fragment methods 2018-06-07 11:49:39 -05:00
Travis Turner
bcec20525b
GoRename Frame to Field in view.go 2018-06-05 22:38:52 -05:00