Commit graph

137 commits

Author SHA1 Message Date
Vladislav
7b6181641c
chore(transaction): Simplify PollExecution() (#2457)
* chore(transaction): Simplify PollExecution()

Remove seqlock_ from transaction. This change is possible because:
- We don't re-use shard_data[0] for multi transactions anymore
- We disarm atomically and poll callbacks are stateless

This makes it safe to call PollExecution() unconditionally that will determine on it's own whether the caller needs to run or is already expired

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-01-26 14:34:17 +03:00
Vladislav
07a6dc0712
feat(transaction): Independent out of order execution (#2426)
Previously, transactions would run out of order only when all shards determined that the keys locks were free. With this change, each shard might decide to run out of order independently if the locks are free. COORD_OOO is now deprecated and the OUT_OF_ORDER per-shard flag should is used to indicate it

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-01-22 10:38:10 +03:00
Roman Gershman
8f454b2dea
fix: allow lock_on_hashtags with any cluster mode (#2443)
Motivation - after we submitted #2429 some smart-ass clients
prevent users from accessing single-node commands like "SELECT".
This PR fixes it by allowing consistent sharding based on hashtags
even with cluster mode disabled.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-01-19 23:44:24 +02:00
adiholden
a11b2a941a
fix(server): dont allow snapshoting in tiering mode (#2438)
* fix(server): dont allow snapshoting in tiering mode

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-01-18 19:40:35 +02:00
Vladislav
bf89c7eac2
chore(transaction): Clean up scheduling code (#2422)
* chore(transction): Clean scheduling code
2024-01-17 17:33:48 +03:00
Roman Gershman
b6f4370ae7
feat: allow throttling tiered writes (#2414)
* feat: allow throttling tiered writes

The throttling is controlled by tiered_storage_throttle_us flag
and can be disabled by passing `--tiered_storage_throttle_us=0`.
This introduces a soft back-pressure during writes.

On my machine `debug POPULATE 10000000 key 1000 RAND` with tiered_storage_throttle_us=0
offloads 12% of all the entries, but with tiered_storage_throttle_us=1 it offloads
almost 100% by prolonging the operation from 0.96s to 1.72s.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-01-15 13:21:23 +02:00
Kostas Kyrimis
25d906bce7
feat: allow round robin sharding in non cluster mode (#2364) 2024-01-08 10:51:15 +02:00
adiholden
c60e4accc6
feat(tiering): add max file size limit (#2344)
* add max file size flag

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-01-02 12:07:34 +02:00
Roman Gershman
fc1a70598d
fix "debug exec" command (#2354)
fix: fix "debug exec" command

It used mutex lock inside Await callback which is prohibited.

In addition, we improved loggings across the transaction code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-01-01 18:29:20 +02:00
Roman Gershman
1fb0a486ac
chore: transaction simplification (#2347)
chore: simplify transaction multi-locking

Also, add the ananlysis routine that determines whether the schewduled transaction is contended with other transaction in a
shard thread.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-31 17:02:12 +02:00
Roman Gershman
5035d4e1e3
chore: expose the multi length in slowlog (#2339)
1. Fix AnalyzeTxQueue to stop crashing for various transaction types.
2. Pass exec command length to slowlog

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-27 16:11:14 +02:00
Roman Gershman
ce7497071c
feat: introduce 'debug tx' command and periodic overload logs (#2333)
This command shows the current state of transaction queues,
specifically how many armed (ready to run) transactions there,
how loaded these queue are and how many locks there are in each shard.

In addition, if a tx queue becomes too long, we will output warning logs about
the state of the queue, in order to be able to identify
the bottlenecks post-factum.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-25 11:48:55 +02:00
Roman Gershman
bbe3d9303b
feat: introduce transaction statistics in the info output (#2328)
1. How many transactions we processed by type
2. How many transactions we processed by width (number of unique shards).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-23 13:18:49 +02:00
Roman Gershman
0c5bb7b894
fix: regression test failures (#2226)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-11-27 21:41:52 +02:00
Kostas Kyrimis
03a6b508e8
chore: add missing doc for spill_file_prefix (#2174)
* chore: add missing doc for spill_file_prefix

* chore: add wording for experimental
2023-11-21 11:56:59 +02:00
Yue Li
00f1e3d578
feat(server): perform eviction upon memory pressure in cache mode (#2084)
* fixes #1936

Eviction Implementation
This patch provides a very simple eviction implementation for the interface mentioned above. In my opinion, the eviction algorithm approximates an LRU policy given that normal buckets always store the most recently accessed data while stash buckets are holding less active data.

The algorithm first selects a small set of segments as eviction targets. Starting from the last slot of the last stash bucket in each of the segments, we walk backward to evict key-value pairs stored in each visited slot. The eviction stopped either when a target memory release goal or the max number of evicted key-value pairs is reached. Therefore, we can upper bound the eviction time through the following two parameters that can be set when DF starts.  Note that these two parameters could be retrieved and changed by user through CONFIG GET and CONFIG SET commands.

---------

Signed-off-by: Yue Li <61070669+theyueli@users.noreply.github.com>
2023-11-01 11:11:27 -07:00
Roman Gershman
15f54be762
chore: measure rss memory and track its peak (#2054)
Up until know we did not have cached rss metric in the process.
This PR consolidates caching of all values together inside the EngineShard periodic fiber
code. Also, we know expose rss_mem_current that can be used internally for identifying
memory pressuring periods during the process run.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-22 19:01:40 +00:00
Shahar Mike
838d01af32
fix(server): Start periodic fiber only once init completes (#2023) 2023-10-15 14:56:55 +03:00
Shahar Mike
96b8dd9ca6
opt(server): Allow round-robin keys between shards based on prefix (#2016)
This will allow some use cases with few busy keys to distribute load
more evenly between threads.

Idea by @dranikpg.

To calculate how many entries are needed in the table I used the
following quick-n-dirty code, to reach <2.5% collision with 100 keys:

```cpp
bool Distribute(int balls = 100, int bins = 100) {
  vector<int> v(bins);
  for (int i = 0; i < balls; ++i) {
    v[rand() % v.size()]++;
  }

  for (int v : v) {
    if (v >= 2) {
      return true;
    }
  }

  return false;
}

int main(int argc, char** argv) {
  int has_2_balls = 0;
  constexpr int kRounds = 1'000'000;
  for (int i = 0; i < kRounds; ++i) {
    has_2_balls += Distribute(100, 100'000);
  }
  cout << has_2_balls << " rounds had 2+ balls in a single bin out of " << kRounds << endl;
}
```
2023-10-15 11:52:44 +03:00
Vladislav
f3c07174aa
feat(search): Plug in polymorphic allocator (#1819)
* feat(search): Plug in polymorphic allocator

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-10-05 18:09:11 +03:00
Roman Gershman
4be9551806
chore: adjust verbosity level 1 not be over-verbose in prod (#1974)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-01 14:31:39 +03:00
Kostas Kyrimis
8dd34b9ce3
fix: small typos on flags (#1953)
* Polish small typos on flags
2023-09-27 15:02:04 +00:00
Shahar Mike
b91435e360
opt(lua): Coordinate single-shard Lua evals in remote thread (#1845)
* opt(lua): !!WIP!! Coordinate single-shard Lua evals in remote thread

This removes the need for an additional (and costly) Fiber.
2023-09-13 11:52:35 +03:00
Vladislav
e020f8734b
fix: Run defrag on dbs > 0 as well (#1737)
* fix: Run defrag on dbs > 0 as well

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-27 13:44:31 +03:00
Roy Jacobson
4001a94b22
chore: Add names to fibers that were missing them (#1667) 2023-08-08 13:01:50 +02:00
Roman Gershman
84d09800c3
chore: refresh helio (#1506)
In addition, add more states to tx local_mask to allow easier debugging.
Finally, add check-fail to verify tx invariants in order to prevent
reaching errorneous states that are nearly impossible to analyze.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-04 16:51:53 +03:00
Roy Jacobson
ea0364329e
fix: null deref in debug log (#1513) 2023-07-04 10:10:29 +03:00
Vladislav
6f78ae5073
fix: call NotifyPending only from tx queue invocations (#1439)
* fix: call NotifyPending only from tx queue invocations

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-06-21 10:26:22 +03:00
Vladislav
6d4d740d6e
fix: Don't remove non-concluding tx from queue on ooo runs (#1427)
* fix: Don't remove non-concluding tx from queue on ooo runs

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-06-18 21:14:28 +03:00
Vladislav
cc067dede9
Search: Basic shard state (#1249)
Implement basic mapping from active index document to integer ids

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-05-28 16:27:32 +03:00
Roman Gershman
ee24029148
feat: enable multi-tx squashing. (#1074)
Make blpop test pass with squashing. The problem was that the txid was not properly reported
back to the testing code.

Also, fixed redundant codepath for defragmentation.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-04-12 16:15:35 +03:00
Roman Gershman
0cbd5f0348
chore: remove fiber related names from the codebase (#1018)
Remove Boost.Fibers mentions and remove fibers_ext mentions.
Done in preparation to switch to helio-native fb2 implementation.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-31 13:33:20 +03:00
Roman Gershman
12abe0bc12
chore: update helio dependency (#984)
Also remove direct references for boost fibers from the code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-24 18:04:05 +03:00
Roman Gershman
f4081f3979 fix: improve consistency around brpop flow
1. Added a test that was breaking earlier.
2. Made sure that multiple waked brpop transaction would not
   snatch items from one another.
3. Fixed watched-queues clean-up logic inside blocking_controller that caused deadlocks.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-17 11:49:23 +02:00
Roman Gershman
c96f637f73 chore: some pytests and logging improvements
1. pytest extensions and fixes - allows running them
   with the existing local server by providing its port (--existing <port>).
2. Extend "DEBUG WATCHED" command to provide more information about watched state.
3. Improve debug/vlog printings around the code.

This noisy PR is a preparation before BRPOP fix that will follow later.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-17 10:52:20 +02:00
Roman Gershman
bac9180602 chore: change thread_local to __thread when possible.
This should reduce the access cost to thread_local objects.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-12 21:57:56 +02:00
Vladislav
2b40a7f324
feat(server): Check locks in heartbeat, allow multiple tx in replica (#815) 2023-02-17 16:50:44 +03:00
adiholden
50f50c8380
feat(server): write journal record with optional await based on flag… (#791)
* feat(server): write journal recorod with optional await based on flag issue #788

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-02-15 09:34:24 +02:00
Vladislav
25db011afc
fix(server): Fix bugs (#797) 2023-02-14 13:42:20 +03:00
Vladislav
4c9b30ca43
feat(server): Auto expiry + small replica refactor (#718) 2023-01-31 12:55:52 +03:00
Vladislav
9536c0a645
Refactor transaction (#697)
* refactor(server): Transaction naming

Signed-off-by: Vladislav <vlad@dragonflydb.io>
2023-01-17 14:53:12 +02:00
ashotland
01b9cbe64d
fix(server): Convert Heartbeat from a periodic task to a fiber (#690)
* feat(server): Add metrics

Signed-off-by: ashotland <ashotland@gmail.com>

Fixes #637

* fix(server): Convert Heartbeat from a periodic task to a fiber

Fixes #685

Signed-off-by: ashotland <ashotland@gmail.com>

Signed-off-by: ashotland <ashotland@gmail.com>
2023-01-16 15:26:14 +02:00
Roman Gershman
613e3b8741
fix(server): Fix a bug with brpoplpush (#677)
fix(server): Fix a bug when an expired transaction stays in watched queue.

Now we remove the transaction from the watched queues in a consistent manner based on the
keys it was assigned to watch.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-01-14 20:18:28 +02:00
Roman Gershman
16a3e557ae feat(server): Support brpoplpush for two shard case.
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-01-12 12:00:10 +02:00
Roman Gershman
9ca636e49d feat(server): Implement brpoplpush for single shard case.
A simple case where both src and dest keys are located in the same shard.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-01-12 12:00:10 +02:00
Boaz Sade
51a78a3ad3
feat(server): using memory defrag with per shard mem info (#616)
Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
2023-01-01 18:50:57 +02:00
Roman Gershman
63b83c5b99
chore: Add tiered_storage_test. (#613)
1. Support tiered deletion.
2. Add notion of tiered entity in "DEBUG OBJECT" output.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-28 10:37:55 +02:00
Roman Gershman
cdc31fc98c
fix: handle corner case when comitted memory is negative (#570)
Set mem_defrag_threshold so that defrag will be trigerred when memory grows.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-19 13:56:20 +02:00
Roman Gershman
23c902d8e9
chore: Update helio dependency (#553)
Switch to using fibers_ext::Fiber.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-09 16:43:41 +02:00
Boaz Sade
5aabc965ba
feat(server): defrag memory counter for total memory access (#537)
Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
2022-12-06 15:27:18 +02:00