featurebase/roaring
Seebs 4d494f6699
shared/generic functionality for iterating holders
This is sort of large, but it's annoyingly difficult to
separate out.

The basic idea is to allow us to have a single holder-iterating
block of code, which is associated with the holder, that can be used
for various things, like the snapshot queue background scan, or
for inspect operations.

We invent the concept of a HolderFilter, which is a thing that
can decide what things in a holder it cares about, and a HolderOperator,
which can also process those things selectively.

In the process, we fix up a couple of subtle bugs in the
inspect logic; specifically, the assumption that the mapped flag could
tell you whether a container was modified by the ops log doesn't
work with mmap, so we have a shiny new flag which is used to track
that, internal to the roaring/container code.

All of this leads to the actual *point* of this exercise, which is
making it easier to create an /inspect endpoint which produces almost
the same data we'd have gotten from `pilosa inspect` on a data directory;
the distinction is that it doesn't try to identify the distinction
between data from disk and data from operations since the file was
loaded. Possibly it should, but it doesn't yet.

The snapshot queue is now implemented using the HolderOperator
design, which requires some subtle changes to how it works, but
overall makes it easier to follow the snapshot queue logic,
and also shares that logic with the way Inspect works.

The holder's snapshot queue is now provided by the server, in
a default environment.

The queueless snapshot queue no longer triggers snapshots on
enqueue -- it turns out that breaks badly, because a key
point about enqueueing a snapshot is that it's safe to do it
*during* a transaction on that fragment, and triggering a
snapshot during a transaction actually causes horrible errors
as the ops log ends up being the old file, which we close.
Related to this, we also need to prevent closed fragments from
trying to snapshot, so we track fragment openness when opening
or closing, and bail on trying to snapshot a fragment which is closed.

We also stop using the queueless snapshot queue during tests,
because that's a horrible idea.

We copy a little bit of the partition logic from the cluster code so
we don't have to expose it all, this lets us check whether the node
we're looking at is the one which should be primary for a given shard,
and if not, identify which node would be. This works only when
pointed at a data directory, for now.

The test cases for the holder have to be internal, because pilosa
doesn't export view/fragment, just Index/Field. This means that the
holder test cases can't just use the test/* package, so they duplicate
some of its logic, approximately.
2020-06-29 15:18:47 -04:00
..
testdata cleanup #1622 2018-09-06 16:27:10 -05:00
btree.go roaring: fix use-after-free in b-tree bitmap update 2020-05-20 12:01:21 -04:00
btree_test.go Don't test quite so many values for BtreeSeek and BtreeDelete 2020-06-08 12:10:40 -05:00
container_stash.go shared/generic functionality for iterating holders 2020-06-29 15:18:47 -04:00
containers_btree.go clarify a few of the TODO comments 2020-05-19 13:50:48 -05:00
containers_slice.go The first implementation of intersect in place 2020-05-06 23:59:07 +02:00
containers_test.go roaring: optimize splat 2020-06-16 13:04:50 -04:00
fuzz_test.go generalize test strings and break out old UnmarshalBinary code 2019-08-05 17:39:47 -05:00
fuzzer.go added go-fuzz testing for roaring ops vs naive implementation 2019-06-25 10:47:53 -05:00
generation_debug.go Sources and Generations: tracking mmapped files 2019-11-12 12:14:29 -06:00
generation_nodebug.go Sources and Generations: tracking mmapped files 2019-11-12 12:14:29 -06:00
inst.go Add license headers to files missing them and CI check to verify they are present. Fixes #1633 2019-04-12 11:30:41 -05:00
naive.go added go-fuzz testing for roaring ops vs naive implementation 2019-06-25 10:47:53 -05:00
naive_test.go Lower scale of some random-value tests 2020-06-08 12:10:40 -05:00
nop_inst.go double the nolint comments, double the checking 2019-10-11 15:17:51 -05:00
README.md Fixed typo 2019-06-17 16:47:28 -05:00
roaring.go shared/generic functionality for iterating holders 2020-06-29 15:18:47 -04:00
roaring_helpers_test.go Improve container/bitmap comparison logic for testing 2020-06-08 12:10:40 -05:00
roaring_internal_test.go roaring: remove invalid uses of unsafe 2020-06-25 11:48:21 -04:00
roaring_nop_paranoia.go Add license headers to files missing them and CI check to verify they are present. Fixes #1633 2019-04-12 11:30:41 -05:00
roaring_nop_sentinel.go switched naive_test.go to table driven tests 2019-06-25 17:25:07 -05:00
roaring_nop_stats.go Add license headers to files missing them and CI check to verify they are present. Fixes #1633 2019-04-12 11:30:41 -05:00
roaring_paranoia.go Add license headers to files missing them and CI check to verify they are present. Fixes #1633 2019-04-12 11:30:41 -05:00
roaring_sentinel.go switched naive_test.go to table driven tests 2019-06-25 17:25:07 -05:00
roaring_stats.go v2.0.0 2019-10-08 14:56:17 -06:00
roaring_test.go shared/generic functionality for iterating holders 2020-06-29 15:18:47 -04:00
source.go Sources and Generations: tracking mmapped files 2019-11-12 12:14:29 -06:00
unmarshal_binary.go shared/generic functionality for iterating holders 2020-06-29 15:18:47 -04:00

The Fuzzer

For complete documentation on go-fuzz, please see: https://github.com/dvyukov/go-fuzz

The fuzzer in relation to the roaring package checks the Bitmap.UnmarshalBinary function found in roaring.go. In order to use the fuzzer, you can follow these steps:

cd $GOPATH/src/github.com/pilosa/pilosa/roaring

go-fuzz-build ./

You must now make the workdir/corpus directory. This is achieved by:

mkdir workdir/corpus

The fuzzer needs some input to start the fuzzing with. Copy some sample Pilosa fragments into the workdir/corpus folder. For example:

cp ~/.pilosa/my-index/my-field/views/standard/fragments/0 workdir/corpus

Once you have copied your sample inputs, you are ready to run the fuzzer:

go-fuzz -bin=roaring-fuzz.zip -workdir=workdir -func=FuzzBitmapUnmarshalBinary

Understanding the Fuzzer Output

The fuzzer will output something similar to the follwoing:

2015/04/25 12:39:53 workers: 8, corpus: 124 (12s ago), crashers: 37, restarts: 1/15, execs: 35342 (2941/sec), cover: 403, uptime: 12s

The most important part of the output is the crashers and cover. The crashers records how many combinations were discovered that fail and the cover tells you how much code is being accessed. For a complete explanation of the output, please see: https://github.com/dvyukov/go-fuzz.

The fuzzer will document the crashers in a folder labeled "crashers." It will record the fragment and the error that was produced in two separate files within this folder. This is the final product.

Happy Fuzzing!