Commit graph

206 commits

Author SHA1 Message Date
Vladislav
be4ef01975
fix(server): Reorder ExecuteAsync callback seqlock check (#873)
fix(server): Reoder cb check

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-02-24 21:55:56 +02:00
Vladislav
03e99a5d96
EVAL multi modes + non atomic modes (#818)
- Implement multi modes for eval
- Implement non atomic mode
- Enhance tests
2023-02-20 09:43:31 +03:00
Vladislav
4ef06e759a
Basic multi modes for MULTI/EXEC (#796)
feat(server): Basic multi transaction modes

This commit adds the notion of multi transaction modes that allow controlling the execution and
locking behaviour of multi transactions.
In general, there are four modes:
- GLOBAL: all commands run within a global transaction. There is no need for recording locks. Lua scripts can theoretically run with undeclared keys.
- LOCK_AHEAD: the transaction locks all keys ahead likewise to a regular transaction and schedules itself.
- LOCK_INCREMENTAL: the transaction determines what shards it has keys in and schedules itself on those shards, but locks only when accessing a new key. This allows other transactions to run ooo alonside with a big multi-transaction that accesses a contended key only at its very end.
- NON_ATOMIC: all commands run separately, no atomicity is provided, likewise to a pipeline

This commit only adds support for the first 3 modes to EXEC commands.

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-02-18 20:18:28 +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
adiholden
72bad6c5ab
fix(replica) : replica will not sync execution multi shard commands as default (#800)
-sfix(replica) : replica will not sync execution multi shard commands as default
2023-02-14 16:30:14 +02:00
Vladislav
3e46fd1318
Refactor initialization phase of transaction (#790)
* refactor(server): Split transaction init

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-02-14 08:32:02 +02:00
Vladislav
6e612e7545
feat(server): Async unlock multi (#774)
* feat(server):Async unlock multi

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-02-11 18:57:02 +02:00
Vladislav
07973d40eb
Update transaction and enable OOO for regular transactions (#769)
* refactor(server): Update ScheduleSingleHop

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-02-09 19:36:55 +02:00
Roman Gershman
46b42e571f
chore(server): track ooo transactions via metrics. (#763)
This change allows to track which transactions are run as out of order.
OOO txs are more performant and inhibit substantially less latency.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-02-07 19:40:25 +02:00
adiholden
4a826fdb7b
bug(transaction): local result needs to be reset on InitByArgs Fixes … (#762)
* bug(transaction): local result needs to be reset on InitByArgs Fixes #752

Signed-off-by: adi_holden <adi@dragonflydb.io>

* add unit test

Signed-off-by: adi_holden <adi@dragonflydb.io>

---------

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-02-06 15:48:12 +02:00
adiholden
4b29dece0c
test(replication test): check data only after replica finished execution (#746)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-02-02 15:08:44 +02:00
Roman Gershman
90eb1d81b7
fix(lua): Fix a deadlock happenning when calling a lua script (#726)
The scenario is described in a unit test that reproduces the issue with high chance.
Also added dragonfly_test in repeat=100 mode to CI.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-01-25 10:16:52 +02:00
ashotland
59bfecad69
feat(server): Allow admin commands in multi (#722)
Needed for sentinel support (#706)

Signed-off-by: ashotland <ari@dragonflydb.io>

Signed-off-by: ashotland <ari@dragonflydb.io>
2023-01-24 15:55:47 +02:00
Vladislav
2df1c6636c
fix(server): Fix multi tx cleanup (#723) 2023-01-24 15:33:43 +03:00
Roman Gershman
ac44a1f7e9
fix(server): zunion now supports variadic arguments (#717)
1. Before that we did no support a real syntax with <numkey> argument,
now we do.

2. Fix warnings.

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

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-01-23 14:06:17 +02:00
adiholden
086edd9707
feat(list family): impl rename journal commands (#704)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-01-19 14:34:25 +02:00
adiholden
dc4306890c
feat(transaction): simplify calc multi trans unique shard count (#672)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-01-18 14:37:29 +02:00
adiholden
f175127837
(generic family): journal support rename command (#698)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-01-18 12:14:18 +02: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
adiholden
1f5811fb78
feat(set family): rewrite set store commands to journal (#691) 2023-01-17 00:27:11 +03:00
Vladislav
1eb227e318
feat(server): Rewrite journal commands (basic) (#651) 2023-01-16 14:52:46 +03: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
adiholden
3065946b9a
feat(replica): support multi transaction command (#634) 2023-01-04 09:11:30 +02:00
adiholden
5d39521de3
feat(replica): Support FlushDB command for replication #580 (#591) 2022-12-25 14:03:49 +02:00
Vladislav
2386b02234
feat(server): Use new journal format (#563) 2022-12-20 16:38:19 +03:00
Vladislav
893c741c14
feat(server): Replication errors & cancellation (#501) 2022-11-22 19:17:31 +03:00
Vladislav
96c9332297
feat(server): Switch to stable state replication (#473)
* feat(server): Switch to stable state replication

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2022-11-17 20:41:33 +02:00
Boaz Sade
91ab423e6a
fix(server): issue with invalid command inside multi #468 (#469)
fix(server): Fix redundant locking in multi transactions

Apparently commands that scheduled themselves using "Schedule()" call
crashed under multi transactions. This has been fixed now inside Transaction code.
It has been covered by DflyEngineTest.MultiRename test.

In addition, this PR fixes #468 that opened the rabbit hole of
nasty bugs under multi transactions.

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

Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-11-09 23:31:19 +02:00
Roman Gershman
2b87088121
fix(list): Fixes blpop failure. (#462)
The bug was that if two push operations where queued together in the tx queue,
and the first push awakes pending blpop, then the PollExecution function would continue with the
second push before switching to blpop, which contradicts the spec.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-11-05 14:43:11 +02:00
Roman Gershman
0925829afb feat(server): Introduce transaction clock.
Partially implements #6.
Before, each shard lazily updated its clock used for the expiry evaluation.
Now, the clock value is set during the transaction scheduling phase and is assigned
to each transaction. From now on DbSlice methods use this value when checking whether
the entry is expired via passed DbContext argument.

Also, implemented transactionally consistent TIME command and
verify that time is the same during the transaction. See
https://ably.com/blog/redis-keys-do-not-expire-atomically for motivation.

Still have not implemented any lamport style updates for background processes
(not sure if it's the right way to proceed).
2022-09-25 23:53:08 +03:00
Roman Gershman
0a1b5eb297
chore(server): rdb save can now save into tcp socket directly. (#317)
In more detail, RdbSaver uses AlignedBuffer that writes into io::Sink in chunks of 4KB.
It's great for the direct file I/O, but bad for sockets that receive blocks of 4KB with garbage
at the end. I improved the code around this and actually simplified the logic, so now AlignedBuffer
is just another Sink that is passed into serializer when writing into files. When sending to
sockets a socket sink is passed instead.

Also many other unrelated changes grouped into this pretty big cr.
1. dashtable readability improvements.
2. Move methods from facade::ConnectionContext - into facade::Service,
   make ConnectionContext a dumb object.
3. Optionally allow journal to be memory only (not backed up by a disk)
   by using a ring buffer to store last k entries in each journal slice. Also renamed
   journal_shard into journal_slice because journal has presence in each DF thread and not
   only in its shards.
4. Introduce journal::Entry that will consolidate any store change that happens in the thread.
5. Introduce GetRandomHex utility function.
6. Introduce two hooks: ServerFamily::OnClose that is called when a connection is closed,
   and ServerFamily::BreakOnShutdown that is called when process exits and any background fibers neet to
   break early.
7. Pull some noisy info logs out of rdb_load class.
8. Snapshot class now has the ability to subscribe to journal changes, thus it can include concurrent changes into the snapshot.
   Currently only journal::Op::VAL is supported (it's part of RDB format anyway).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-09-20 11:09:03 +03:00
Roman Gershman
de9369f518
chore(server): update license text (#312) 2022-09-19 09:01:10 +03:00
Vladislav
16b6b11cf2
feat(server): Implement MOVE command (#298)
* feat(server): Implement MOVE command

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Co-authored-by: Vladislav Oleshko <vlad@dragonflydb.io>
2022-09-18 20:57:12 +03:00
Roman Gershman
3bbdb8e4b1
feat(journal): Introduce basic journal support. (#211)
1. No entries data is written into a journal yet.
2. Introduced a state machine to start and stop journal using a new auxillary command "dfly".
3. string_family currently calls an universal command Journal::RecordEntry that should
   save the current key/value of that entry. Please note that we won't use it for all the operations
   because for some it's more efficient to record the action itself than the final value.
4. no locking information is recorded yet so atomicity of multi-key operations is not preserved for now.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-07-17 21:12:50 +03:00
Roman Gershman
32f47be034
fix(lua): Fix few lua-related bugs (#157)
1. Correctly parse keys for EVAL command.
2. Support PUBLISH within lua.
3. Remove spurious failure in debug-mode with the increased verbosity level.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-06-16 13:41:09 +03:00
Roman Gershman
4ec2538204
fix(transaction): Fix rare deadlock case - fixes #150. (#155)
In rare cases a scheduled transaction is not scheduled correctly and we need
to remove it from the tx-queue in order to re-schedule. When we pull it from tx-queue
and it has been located at the head, we must poll-execute the next txs in the queue.

1. Fix the bug.
2. Improve verbosity loggings to make it easier to follow up on tx flow in release mode.
3. Introduce /txz handler that shows currently pending transactions in the queue.
4. Fix a typo in xdel() function.
5. Add a py-script that reproduces the bug.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-06-15 16:53:27 +03:00
Ryan Russell
a049128ab6
Improving Readability r3 (#75)
Signed-off-by: Ryan Russell <git@ryanrussell.org>
2022-06-01 19:31:36 +03:00
Roman Gershman
114e8bec5d Fixes #41.
1. Found dangling transaction pointers that where left in the watch queue. Fix the state machine there.
2. Improved transaction code a bit, merged duplicated code into RunInShard function, got rid of RunNoop.
3. Improved BPopper::Run flow.
4. Added 'DEBUG WATCH' command. Also 'DEBUG OBJECT' now returns shard id and the lock status of the object.
2022-05-27 12:20:01 +03:00
Roman Gershman
5e4aa0a1a8 Handle OOM errors for more types. Fix clang warnings and errors 2022-05-18 21:53:49 +03:00
Roman Gershman
797c8121b1 Limit table growth according to maxmemory.
1. Make EngineShardSet to be a process singleton instead of a variable passed everywhere.
2. Implement a heuristic of updating free memory per shard.
3. Make sure that SET command returns OOM when a database reaches its limits.
2022-05-16 08:19:32 +03:00
Roman Gershman
c34e7c6d44 Implement ZUNIONSTORE.
Fix some bugs in transactional framework to support irregular commands.
Lay out groundwork for supporting XXX-STORE other commands in zsets.
2022-05-07 20:38:18 +03:00
Roman Gershman
5c191e31d4 Prepare transactional code to cope with irregular multi-key commands like ZUNIONSTORE 2022-05-01 22:23:19 +03:00
Roman Gershman
afd52d5571 Clean-ups in transaction code. 2022-04-29 15:50:20 +03:00
Roman Gershman
b36c16b314 Implement single shard use-case for rpoplpush. Some BLPOP related refactoring 2022-04-28 19:05:51 +03:00
Roman Gershman
72e90bb729 More work on blocking commands like BLPOP.
Fixes #1 and fixes #24.
2022-04-27 10:42:35 +03:00
Roman Gershman
7f8346cded Implement DEBUG RELOAD option.
Fix c++ and openssl deprecation warnings.
2022-04-12 11:29:42 +03:00
Roman Gershman
49781e8daf Some bug fixes.
closes #19 and closes #20.
2022-04-08 06:53:22 +03:00
Roman Gershman
abbefd0bc4 More bug fixes.
1. RENAME now unblocks blpop/brpop.
2. Fix a deadlock bug with blpop running with the same key multiple times.
2022-04-06 10:32:42 +03:00