Comments (3)
See https://ably.com/blog/redis-keys-do-not-expire-atomically for motivation.
if we use transactions to set expiry or to access multiple possibly expired items, we should use a consistent clock value during the transaction execution.
current behavior: we use real clock to set expiry and to test it.
from dragonfly.
high level design
We can use lamport clock mixed with the wall clock.
- When we start a transaction we sample the wall clock, and bind its value to that transaction.
- When we perform the operations on DbSlice we should use the clock value from that transaction.
For that we should replace all DbSlice interfaces likeFindExt(DbIndex db_ind, std::string_view key) const;
to
FindExt(const Context& cntx, std::string_view key) const;
and pass the clock viaContext
. In fact, I will probably adapt the interfaces ASAP. - DbSlice::now_ms_ should disappear.
- We do delete items outside of transactions (active/bakground expiry) and this is why we need the lamport clock semantics.
We will provide a shard levelnow_ms_
clock updated transparently by incoming transactions based on
max(old, new)
logic. This won't require any walltime sampling - just a simple integer update.
Background processes will use this clock and it will be guaranteed that this clock won't delete items that the ongoing
transaction does not consider expired.
We can transparently update shard clock clock insideEngineShard::RunInShard
method .
Some notes:
-
sampling high-resolution clock is relatively expensive (~100ns CPU time) - but absl::GetCurrentTimeNanos() is probably faster. I use it in
EngineShard::Heartbeat
. We should add the explicit benchmarks to dragonfly_test -
(copy them from https://github.com/romange/gaia/blob/master/base/walltime_test.cc#L155)
-
Once we get rid of
UpdateExpireClock
calls in heartbit, we can decrease the frequency of heartbit and get rid of hz flag because todayhz=1000
is only because we must update expire clock every ms.
from dragonfly.
was fixed in 1.0
from dragonfly.
Related Issues (20)
- FR: Add maxclients in INFO and /metrics HOT 3
- `DEBUG POPULATE` OOM
- failed starting, not enough memory (docker)
- Docker latest version 1.17 when provided volume param still doesnt preserve the data on disk
- sanitizers crash on tiered storage test
- Please report replication lag zero while full sync
- reapply slots into new config from the finished migrations
- crash in slot migration
- Add support for Pub/Sub ACLs HOT 2
- improve traffic logger HOT 4
- implement json.merge
- deadlock in test_replication_all HOT 2
- deadlock in test_maxclients HOT 2
- crash on test_no_tls_on_admin_port HOT 1
- fixes for v1.18.0 HOT 5
- deadlock in test_client_kill HOT 1
- track and expose lua memory usage HOT 1
- JSON.OBJKEYS returns a nested array
- segfaults in test_config_enable_tls
- Increase coverage for JSON commands in regression tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dragonfly.