Commit graph

633 commits

Author SHA1 Message Date
hphamMolecula
8f1349543f
Merge branch 'master' into sup-145 2022-02-14 14:40:12 -06:00
Hoang Pham
63b5eed010 SUP-145: Removed shard list in "shard unavailable" error log 2022-02-14 10:10:04 -06:00
Seebs
96ab9314d1 use task pool for executor workers
This adopts the task pool functionality to let us spawn new worker
threads when worker threads are blocked. The underlying reason for
this is the same as the reason for the previous worker-pool-growing
strategy; while our design persistently has at least one thing which
can proceed, it can be the case that there are N things blocked,
where N is the size of our worker pool. Blocked workers shouldn't
count against our desired number of workers.

Originally, the intent was to thread this into RBF, and provide
backpressure from RBF on the pool when blocking on writes. Unfortunately,
that's not good enough, because while a write is blocked, the Qcx
calling it is *also* holding the Qcx's mutex, which means that any other
NewTx on that Qcx will *also* block. So we need to block for the
entire time of the NewTx.

Removing the existing worker spawning code resulted in a subtle
and maybe-harmless change; prior to this, each invocation of `mapperLocal`
would hold a lock, which meant that all the tasks for a given local mapper
would be put in the queue *sequentially*, ensuring that they'd all be
picked up by workers before things from later workers.

With the new pushback, that's not, strictly, necessary. Also, if you
disable it, you can end up with 300,000 goroutines at once, most of them
blocked.

A smallish run does, in fact, eventually complete anyway -- it will
indeed keep making workers until everything gets one. However, while
it's *correct*, it's also noticably *slower*. The same test workload
goes from around 33 seconds to a bit over 40 seconds when that lock
isn't present. (But that's with an extremely small WAL write cap
introduced to make the previous deadlock possible.)

With large numbers of shards, the practical impact is that you can
have quite a lot of things in process, with hundreds of goroutines
each, all blocked waiting for one writer. If we force them to all be
processed at the same time, all the reads that are connected to
each other are much more likely to get all processed at once, before
something new comes along.

In short, that lock isn't strictly necessary but it seems to help
noticably with performance and reduce simultaneous goroutines
significantly.
2022-02-14 09:56:20 -06:00
Ben Johnson
6d06f5550b Restrict max-memory to Extract() calls only 2022-02-11 14:19:56 -06:00
Matthew Jaffee
c2ed9ecdba remove InternalQueryClient 2022-02-07 15:10:10 -06:00
Ben Johnson
f824117df9 Fix GroupBy with multiple offset int groups 2022-02-04 09:36:59 -07:00
Matthew Jaffee
70ea784d41 don't mind me, just submitting stuff that doesn't even compile and
then getting confused by linter errors
2022-02-02 20:56:18 -06:00
Todd Gruben
d7c082b515 add timestamp formating to type FieldRow used in GroupBy 2022-01-31 12:32:05 -06:00
Ben Johnson
9ebf0e2119 Upgrade go.mod to featurebase/v3 2022-01-21 10:57:05 -07:00
reesporte
cf483aca77 distinct on timestamps can reduce now 2022-01-10 13:07:57 -06:00
reesporte
72adb177ae Merge branch 'master' into percentile-timestamp-decimal 2022-01-03 11:12:23 -06:00
Ben Johnson
310584b0d8 Add job & worker metrics 2021-12-28 10:01:18 -07:00
Matthew Jaffee
7826c06eee use atomics for currentWorker to avoid race 2021-12-18 09:04:04 -06:00
Seebs
8974014d57 too tired to be writing code 2021-12-17 22:48:40 -06:00
Seebs
1439c316d3 read-only lock for check of shutdown 2021-12-17 22:25:01 -06:00
Seebs
9a2a8f964c fix silly typo in worker pool downscaling 2021-12-17 22:22:27 -06:00
Seebs
8f217ab099 scale down worker pool when it's large
if we have more than twice our starting worker pool, and have had no
tasks when checking the queue for multiple rounds, send a job telling
the system to retire a worker. eventually we'll get down to about 2x
the starting pool size if we stay idle.
2021-12-17 22:05:41 -06:00
Seebs
9945575bf1 create a new worker every so often if progress isn't happening
this is very approximate and may be a mess and may be unbounded, but
in practice i think it should be okay. if it's not we'll have an
adventure.
2021-12-17 21:57:38 -06:00
Seebs
29f5f6d7c2 copy things rows after getting them and before their finishers during writes
When a qcx is a write, every Tx under it closes immediately, thus
invalidating all returned data. Thus, if you do a Not() inside a Store(),
you're doing a difference on an existence row and some other row
call... and both of those rows were run, individually, as separate
transactions that got invalidated the moment they were fetched. Oops.
2021-12-17 15:09:25 -06:00
Matthew Jaffee
7935624549 implement percentiles on timestamp/decimal, still needs tests 2021-12-10 15:21:29 -06:00
reesporte
48aef0c8a4 add copyright notice back in
```bash
for file in `cat diffys`; do
   printf '%s\n%s\n' "// Copyright 2021 Molecula Corp. All rights reserved." "$(cat $file)" >$file;
done
```
2021-12-10 11:01:04 -06:00
reesporte
4c53f86e82 removed license from each go file
i used this script, a little clunky but it got the job done

```bash
for file in `find . -type f -print | grep '\.go'`; do
    sed '1,/^\/\/ limitations under the License.$/d' $file > $file.tmp;
    result=`cat $file.tmp`
    if [[ result != "" ]]; then
        gofmt $file.tmp &> /dev/null;
        if [[ $? == 0 ]]; then
            mv $file.tmp $file && gofmt -w $file;
        else
            rm $file.tmp;
        fi
    else
        rm $file.tmp;
    fi
done
```
2021-12-10 09:17:17 -06:00
reesporte
4f03228968 fix count on distinctTimestamp
adds the ability to get the count of a distinct call to a timestamp field
2021-12-06 11:57:17 -06:00
Matthew Jaffee
58b4f40cdc enable TopK on mutex fields
I think it was just an oversight that it wasn't, because this seems to work
2021-12-03 16:41:49 -06:00
reesporte
ff39b76143 remove extra line smh my head 2021-11-19 09:32:41 -06:00
reesporte
0adfa75188 add unit test
we can avoid regressions with a simple unit test that checks that timestamp
ValCounts have the appropriate values in comparisons
2021-11-19 09:23:01 -06:00
reesporte
8f85a9e88d fix bug where timestamp val is wrong in Min/Max 2021-11-18 17:27:13 -06:00
reesporte
ea96c10114 fix typo 2021-11-17 09:10:50 -06:00
reesporte
6419a87797 use util function for formatting timestamp 2021-11-17 09:07:08 -06:00
reesporte
f8e93871c0 refactor safeCopy to pure function and add unit test 2021-11-17 08:51:28 -06:00
reesporte
b3b536505d fix presentation of timestamps from a groupby pql call 2021-11-15 17:15:44 -06:00
reesporte
6d6cf7e51f fix presentation of timestamps from a distinct pql call 2021-11-15 17:15:44 -06:00
Todd Gruben
2ddcbce8ad fix govet and gofmt errors in existing code 2021-10-29 13:14:27 -05:00
reesporte
968ce78c73 remove ShardSlice entirely 2021-10-27 17:05:56 -05:00
reesporte
7c885c8130 export ShardSlice 2021-10-26 15:39:06 -05:00
Seebs
3ef25e4a16 rework executor's per-shard union to use UnionInPlace
The actual code here is mostly jaffee's, but I've reworked it some.

This doesn't directly seem to be using UnionInPlace, but really it
is.

The actual logic inside (*Row).Union is a mess and probably silly
in a few ways, but hardly matters. The important part is that,
instead of calling it once per child as we get them, we gather
all of them at once and then call it on all of them. That gets
us a call to (*Row).Union that does a very elaborate dance to
compute a call to (*rowSegment).Union on the only segment present
in each of those rows, which then does a simpler thing to
call (*Bitmap).Union() with the first response as a receiver
and the rest as parameters, and THAT then ends up calling either
unionIntoTargetSingle() if there's only one other bitmap,
or using UnionInPlace on a Freeze() of the first bitmap, which
gets us (we hope) the benefits of the fancy UnionInPlace logic.

Every part of this is a reminder that we really need to replace
roaring and also the Row/rowSegment stuff some day.
2021-09-29 11:31:13 -05:00
rachithrr
f549dae625 CORE-777: Added DecimalAgg field in GroupCount to output decimal sum
-created groupCountDecimal
-added test
2021-09-16 09:43:13 -05:00
Ben Johnson
6bf854862b Handle SQL WHERE clause 2021-08-26 08:25:16 -06:00
Seebs
ab9b70d7e8 mapperLocal: actually leave loop on read from done channel
staticcheck points out that the break is otherwise an ineffective
break because it just ends the current case clause of the switch
it's in, which is true.
2021-08-18 13:45:36 -05:00
Ben Johnson
60d534c505 Limit translation memory & add max query memory config 2021-08-02 15:28:00 -06:00
Ben Johnson
d16978f5dc Add max memory limit to Extract() to prevent OOM
This commit changes the Extract() query to return an error if the
result set gets too large in order to prevent out-of-memory (OOM)
panics.
2021-08-02 08:20:12 -06:00
Mahesh Arumugam
858f889745 FeatureBase Renaming: changing go.mod module name for featurebase 2021-07-19 09:20:30 -07:00
Mahesh Arumugam
357caf68c3 Fix percentile query: field is mandatory (should not crash), fieldnames can be unquoted 2021-06-24 15:10:05 -07:00
nagamocha3000
b1d18a1ba3 Make percentile checker in test-case match executor implementation 2021-06-03 22:14:05 +03:00
nagamocha3000
af83205032 Fix percentile overflow error 2021-06-02 21:28:07 +03:00
Nia Weiss
a8f7ec4a12
execute like queries on the primary's key translation database
This works around an issue where unreplicated keys will not be matched everywhere.
This also avoids the cost of creating millions of bolt read transactions and allocating strings.
2021-05-27 14:45:10 -04:00
Nia Weiss
a72f6425af
add an option to open a postgres transaction in lookup so it isnt actually a lookup 2021-05-26 14:07:52 -04:00
Todd Gruben
b25ad81e67 restore without restart 2021-05-21 09:27:08 -05:00
Seebs
1c7a6da37b write operations can cause deadlocks in GetTx
The GetTx logic is deeply broken, this DOES NOT fix the underlying
bug.

When any call anywhere in a given set of calls has a top-level write,
we perform all transactions as write transactions, and we do not cache or
share those transactions. This means that anything which causes a
second GetTx for the same index/shard deadlocks against itself.

The two easy to find cases by casual inspection are time quantums
and Not queries, so this addresses those, but this should NOT be
considered a general fix.
2021-05-20 16:41:38 -05:00
Maxton Huff
d9d360aa4d
Merge branch 'master' into longmessage 2021-05-20 10:17:04 -05:00