featurebase/dax
Seebs 54dbeec1af support null/non-null tests for non-BSI fields
There's a lot going on here. First, we were treating "the test is
a Condition" as implying BSI, which it doesn't anymore. Second, the
behavior of conditions was weird and BSI-specific. Third, we had
to propagate these changes and features throughout a bunch of code,
including both the core featurebase code and the DAX replacements/copies
of it, plus the SQL3 layer.

We refactor this so that tests for equality and inequality work for
non-BSI fields, so now if you accidentally use `==` in a Row call
on a non-BSI field, it still works; that's not specific to BSI
fields anymore.

We add a TrackExistence flag to fields, and propagate it through
things like our protobuf code, etcetera, so that we can successfully
create fields. Newly-created fields get this by default, because
we add it unconditionally to them, but the paths that are being
called with existing fields don't add it. So, when we "create"
(really, just load the definition of) a field from something stored
in the schema, we don't add TrackExistence to it, but any path to
creating a new field should.

A time quantum field with NoStandardView will *effectively*
lack TrackExistence.

For sets, mutexes, and time quantums with a standard view, anything
that sets bits will also set a corresponding bit for the record in
a new "existence" view. This allows us to distinguish between an
empty set and a null, and also allows null checks to be constant-time.

When clearing bits, we don't clear existence bits EXCEPT that if
you clear a bit in a mutex, *and the bit actually existed*, we clear
the existence bit. For sets and time quantums, clearing bits never
clears the existence bit.

Deleting records clears the existence bit.

We also add code to the `batch` subpackage to generate suitable
existence field bitmaps and import them. This logic correctly handles
empty sets and nils. The `batch` package does not allow specification
of anything equivalent to clearing a single bit from an existing
record, so we don't have to deal with the mutex complexity in that
case, which is good because it would be impossible.

This requires a number of other subtle changes, such as allowing
new fields to have more than one FieldOption specified for them.

We also drop the handful of implementation bits relating to the
"fullySorted" internal-use-only import flag, which existed only to
support the JSON ingest API, which we've removed.

The most dangerous part of this is that the mutex semantics are
impossible to implement on top of our existing API, because they
require us to know, not how *many* bits we cleared, but which
*specific* bits we cleared. I've implemented this as a new Tx method,
which is almost certainly going to be tech debt one day; if we some
day drop the Import API, we should remove that.

The testing for this is only currently covering the Set/Clear
behavior of PQL, and the Import API. The batch tests haven't been
written yet.

Fields that don't have existence tracking enabled refuse to perform
null/not-null tests. They should also report themselves as having
no null values -- if a record exists, sets in it are considered
empty rather than null.

The SQL3 support requires a number of subtle modifications to both
featurebase and some addon tooling. The essential thing is dropping
the unconditional translation of nil slices to non-nil empty slices
in translateResult, both in the executor and the orchestrator. We
also modify the logic that handles generating results from Extract
calls, to ensure that non-null sets get an empty slice created for
them even if they never have any values assigned.

The expected results for some tests are different now; we expect to
get nil slices, rather than 0-length non-nil slices, for fields which
were never written for a given record. Most tests were not changed.
(In every case, if a test was failing, I actually checked the logic
before changing expected results. This required a lot of tracking down
of edge cases.)

The batch package now rejects as an error attempts to clear single
bits from mutex fields, because so far as I can tell it's simply
impossible to have a roaring import that specifies the correct semantics
there; you can't tell whether to clear an existence bit without
access to the currently-set bits, which the batch API doesn't have.
We already supported the special case of specifying a clear value
of nil for clearing a mutex field; now that is the only allowed
value for a mutex field to have in row.Clears.

We change the logic for fixing up incoming view names (in two places)
to stop assuming that any view in a time field other than "" that does
not have viewStandard as a prefix is a partial time quantum name that
should have "standard_" prepended to it. This allows us to submit
bitmaps for "existence" to time quantum fields and not have them
silently transformed into "standard_existence" because that's what we'd
do with "202203".

We drop the field ClearBits method, which was totally unused.

We drop the sliceDifference function, which was used in a previous
mutex implementation and hasn't been used in ages, and the test
case for it, and the helper function used only by that test case.
2023-03-24 16:01:09 -05:00
..
computer Add HasDirective to dax.Node struct to force Directive on restart (#2335) 2023-03-21 13:22:16 -05:00
controller Cloud 1457 (#2347) 2023-03-23 16:20:45 -04:00
http Remove MDS and replace it with Controller (#2219) 2023-01-30 16:54:12 -06:00
migrations Sqldb rip boltdb (#2341) 2023-03-22 08:54:13 -05:00
models Sqldb rip boltdb (#2341) 2023-03-22 08:54:13 -05:00
queryer support null/non-null tests for non-BSI fields 2023-03-24 16:01:09 -05:00
server Sqldb rip boltdb (#2341) 2023-03-22 08:54:13 -05:00
snapshotter Sqldb rip boltdb (#2341) 2023-03-22 08:54:13 -05:00
storage Cloud 1358 bolt postgres (#2286) 2023-03-20 09:02:22 -05:00
test Add tests cases for coverage in expressiontypes.go (#2345) 2023-03-23 14:17:06 -05:00
writelogger Support for setting individual DatabaseOptions (#2231) 2023-02-06 08:50:28 -06:00
address.go Database isolation: Balancer (#2407) 2023-01-19 22:10:08 +00:00
address_test.go Sync from private repo to commit 12d608c80d 2022-12-12 09:01:20 -08:00
controller.go Add Drop Database and Drop Table support (#2208) 2023-01-23 19:59:47 -06:00
dax.go Remove MDS and replace it with Controller (#2219) 2023-01-30 16:54:12 -06:00
directive.go Remove MDS and replace it with Controller (#2219) 2023-01-30 16:54:12 -06:00
directive_version_test.go Sqldb rip boltdb (#2341) 2023-03-22 08:54:13 -05:00
errors.go Cloud 1457 (#2347) 2023-03-23 16:20:45 -04:00
Makefile Cloud 1358 bolt postgres (#2286) 2023-03-20 09:02:22 -05:00
migrations.go Cloud 1358 bolt postgres (#2286) 2023-03-20 09:02:22 -05:00
node.go Add HasDirective to dax.Node struct to force Directive on restart (#2335) 2023-03-21 13:22:16 -05:00
README.md introduce performance counters and system table fanout, plus refactor metrics (#2363) 2023-01-19 21:35:02 +00:00
role.go Database isolation: Balancer (#2407) 2023-01-19 22:10:08 +00:00
schema.go Support for setting individual DatabaseOptions (#2231) 2023-02-06 08:50:28 -06:00
service_manager.go tweak a bunch of logging and config (#2234) 2023-02-03 14:59:07 -06:00
snapshot.go remove version/directive stuff from other snapshot endpoints 2023-01-10 23:22:58 +00:00
table.go support null/non-null tests for non-BSI fields 2023-03-24 16:01:09 -05:00
table_test.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
time.go Add DAX - full list of squashed commits below 2022-12-12 09:01:20 -08:00
transaction.go Database isolation: Balancer (#2407) 2023-01-19 22:10:08 +00:00
versioned_partition.go first cut at removing all the shard/field/partition versioning 2023-01-10 23:27:40 +00:00
versioned_shard.go first cut at removing all the shard/field/partition versioning 2023-01-10 23:27:40 +00:00
workerjob.go Database isolation: Balancer (#2407) 2023-01-19 22:10:08 +00:00
workerjob_test.go Add DAX - full list of squashed commits below 2022-12-12 09:01:20 -08:00

DAX

DAX encapsulates anything which covers all of the services which make up the "disaggregation of storage and compute" project. Initially, this will include integration tests which pull in things like Metadata Services (MDS), including the Controller, as well as FeatureBase and IDK-based ingesters.

Setting up the tests

The DAX test currently requires docker images for: featurebase and datagen.

If at any point you run into problems with go mod failing to reference a private repo, make sure that you have gitlab.com/featurebasedb in your GOPRIVATE environment variable.

Note that during the docker image build step, go mod vendor is run, which creates a vendor directory in the root directory, and copies that to docker during the build stage. Just be aware of this; you may want to remove that vendor directory after you're done building docker images.

Possible Configuruation

The following were relevent when the dax code was in a separate repository. These may no longer be relevant.

I needed to but this in my ~/.profile file:

export GOPRIVATE=github.com/featurebasedb,gitlab.com/featurebasedb

And this in my ~/.gitconfig

[url "ssh://git@github.com/"]
	insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
	insteadOf = https://gitlab.com/

Then make docker ran successfully.

Build the FeatureBase docker image

  • Check out the dax branch of the featurebase repository.
  • Run make docker-image-featurebase to build the docker image
  • You should now have an image in docker named dax/featurebase with the tag latest.

Build the Datagen docker image

  • cd <featurebase_repo_root>/idk
  • Run make docker-image-datagen to build the docker image
  • You should now have an image in docker named dax/datagen with the tag latest.

Running the tests

  • Check out the dax branch of the featurebase repository.
  • Change into the dax directory: cd dax
  • Run make test-integration.