From ae3812da8511267fd0b0144b1bf04606de350589 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Thu, 11 Jul 2024 19:57:25 +0200 Subject: [PATCH] feat(ds): allow to turn monotonic timestamps off for DB That tells implementation how to assign timestamps to messages. Current implicit default is now `force_monotonic_timestamps => true`. --- .../src/emqx_ds_builtin_local_meta.erl | 1 - apps/emqx_durable_storage/src/emqx_ds.erl | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/emqx_ds_builtin_local/src/emqx_ds_builtin_local_meta.erl b/apps/emqx_ds_builtin_local/src/emqx_ds_builtin_local_meta.erl index dbc68cd2c..0f13ac4b3 100644 --- a/apps/emqx_ds_builtin_local/src/emqx_ds_builtin_local_meta.erl +++ b/apps/emqx_ds_builtin_local/src/emqx_ds_builtin_local_meta.erl @@ -151,7 +151,6 @@ ensure_monotonic_timestamp(ShardId) -> %%================================================================================ -record(s, {}). --define(timer_update, timer_update). init([]) -> process_flag(trap_exit, true), diff --git a/apps/emqx_durable_storage/src/emqx_ds.erl b/apps/emqx_durable_storage/src/emqx_ds.erl index 7f6996bd7..57d8c9234 100644 --- a/apps/emqx_durable_storage/src/emqx_ds.erl +++ b/apps/emqx_durable_storage/src/emqx_ds.erl @@ -169,6 +169,13 @@ -type generic_db_opts() :: #{ backend := atom(), + %% Force strictly monotonic message timestamps. + %% Default: `true'. + %% Messages are assigned unique, strictly monotonically increasing timestamps. + %% Those timestamps form a total order per each serialization key. + %% If `false' then message timestamps are respected; timestamp, topic and + %% serialization key uniquely identify a message. + force_monotonic_timestamps => boolean(), serialize_by => clientid | topic, _ => _ }.