Skip to content

Commit

Permalink
Merge pull request #51 from aeternity/ta-rocksdb-1.8.0
Browse files Browse the repository at this point in the history
Towards version 7.10.2 of rocksdb via version 1.8.0 or erlang_rocksdb
  • Loading branch information
ThomasArts authored Mar 19, 2024
2 parents f2b6116 + 16d0533 commit 296813e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ executors:
otp:
type: string
docker:
- image: aeternity/builder:bionic-<< parameters.otp >>
- image: aeternity/builder:focal-<< parameters.otp >>
user: builder
environment:
ERLANG_ROCKSDB_BUILDOPTS: "-j2"
ERLANG_ROCKSDB_OPTS: "-DWITH_SYSTEM_ROCKSDB=ON -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_BZ2=ON -DWITH_ZSTD=ON"


jobs:
build_and_test:
Expand All @@ -31,4 +33,4 @@ workflows:
- build_and_test:
matrix:
parameters:
otp: ["otp23", "otp24"]
otp: ["otp24", "otp25", "otp26"]
6 changes: 5 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{deps,
[
{sext, "1.8.0"},
{rocksdb, {git, "https://gitlab.com/seanhinde/erlang-rocksdb.git", {ref,"9ae37839"}}},
{rocksdb, {git, "https://gitlab.com/barrel-db/erlang-rocksdb.git", {tag,"1.8.0"}}},
{hut, "1.4.0"}
]}.

Expand All @@ -14,6 +14,10 @@
deprecated_function_calls
]}.

{dialyzer, [{plt_apps, all_deps},
{base_plt_apps, [erts, kernel, stdlib, mnesia ]}
]}.

{profiles,
[
{test,
Expand Down
4 changes: 2 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{"1.2.0",
[{<<"hut">>,{pkg,<<"hut">>,<<"1.4.0">>},0},
{<<"rocksdb">>,
{git,"https://gitlab.com/seanhinde/erlang-rocksdb.git",
{ref,"9ae378391ffc94200bde24efcd7a4921eba688d0"}},
{git,"https://gitlab.com/barrel-db/erlang-rocksdb.git",
{ref,"fced5f637de7991c5948e28414ba3790b0476c4b"}},
0},
{<<"sext">>,{pkg,<<"sext">>,<<"1.8.0">>},0}]}.
[
Expand Down
22 changes: 12 additions & 10 deletions src/mrdb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ release_snapshot(SHandle) ->
%% <li> `{tx, TxOpts}' - A `rocksdb' transaction with sligth modifications</li>
%% <li> `batch' - A `rocksdb' batch operation</li>
%% </ul>
%%
%%
%% By default, transactions are combined with a snapshot with 1 retry.
%% The snapshot ensures that writes from concurrent transactions don't leak into the transaction context.
%% A transaction will be retried if it detects that the commit set conflicts with recent changes.
Expand Down Expand Up @@ -320,7 +320,7 @@ incr_attempt({I,O}, {Ri,Ro}) when is_integer(I), is_integer(O),
end;
incr_attempt(_, _) ->
error.

retry_activity(F, Alias, #{activity := #{ type := Type
, attempt := A
, retries := R} = Act} = Ctxt) ->
Expand Down Expand Up @@ -532,7 +532,7 @@ rdb_transaction(DbRef, Opts) ->
rocksdb:transaction(DbRef, Opts).

rdb_transaction_commit_and_pop(H) ->
try rdb_transaction_commit(H)
try rdb_transaction_commit(H)
after
pop_ctxt()
end.
Expand All @@ -559,6 +559,7 @@ rdb_release_batch(H) ->
rocksdb:release_batch(H).

%% @doc Aborts an ongoing {@link activity/2}
-spec abort(_) -> no_return().
abort(Reason) ->
case mnesia_compatible_aborts() of
true ->
Expand Down Expand Up @@ -846,7 +847,7 @@ update_index_do_bag(Ixs, Name, R, Key, Obj, Opts) ->
not_found
end
end.

update_index_do([{_Pos,ordered} = Ix|Ixs], Name, R, Key, Obj, Rest, Opts) ->
Tab = {Name, index, Ix},
#{ix_vals_f := IxValsF} = IRef = ensure_ref(Tab, R),
Expand Down Expand Up @@ -1018,7 +1019,7 @@ alias_of(Tab) ->
%% and when releasing, all batches are released. This will not ensure
%% atomicity, but there is no way in rocksdb to achieve atomicity
%% across db instances. At least, data should end up where you expect.
%%
%%
%% @end
-spec as_batch(ref_or_tab(), fun( (db_ref()) -> Res )) -> Res.
as_batch(Tab, F) ->
Expand Down Expand Up @@ -1321,7 +1322,7 @@ rdb_fold(Tab, Fun, Acc, Prefix, Limit) when is_function(Fun, 3)
true = valid_limit(Limit),
mrdb_select:rdb_fold(ensure_ref(Tab), Fun, Acc, Prefix, Limit).

valid_limit(L) ->
valid_limit(L) ->
case L of
infinity ->
true;
Expand Down Expand Up @@ -1546,8 +1547,9 @@ rdb_iterator(R) -> rdb_iterator(R, []).
rdb_iterator(R, Opts) ->
rdb_iterator_(R, read_opts(R, Opts)).

rdb_iterator_(#{db_ref := DbRef, cf_handle := CfH, activity := #{type := tx, handle := TxH}}, ROpts) ->
rocksdb:transaction_iterator(DbRef, TxH, CfH, ROpts);
rdb_iterator_(#{cf_handle := CfH, activity := #{type := tx, handle := TxH}}, ROpts) ->
%% Note: versions before 1.8.0 expected DbRef as first argument
rocksdb:transaction_iterator(TxH, CfH, ROpts);
rdb_iterator_(#{db_ref := DbRef, cf_handle := CfH}, ROpts) ->
rocksdb:iterator(DbRef, CfH, ROpts).

Expand All @@ -1558,11 +1560,11 @@ rdb_merge_(#{db_ref := DbRef, cf_handle := CfH}, K, Op, WOpts) ->
rocksdb:merge(DbRef, CfH, K, Op, WOpts).

write_opts(#{write_opts := Os}, Opts) -> Os ++ Opts;
write_opts(_, Opts) ->
write_opts(_, Opts) ->
Opts.

read_opts(#{read_opts := Os}, Opts) -> Os ++ Opts;
read_opts(_, Opts) ->
read_opts(_, Opts) ->
Opts.

-define(EOT, '$end_of_table').
Expand Down
7 changes: 4 additions & 3 deletions src/mrdb_index.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
, index_ref/2
]).

-record(mrdb_ix_iter, { i :: mrdb:iterator()
-record(mrdb_ix_iter, { i :: mrdb:mrdb_iterator()
, type = set :: set | bag
, sub :: mrdb:ref() | pid()
, sub :: pid() | mrdb:db_ref()
}).

-type ix_iterator() :: #mrdb_ix_iter{}.
Expand All @@ -22,7 +22,7 @@

-type object() :: tuple().

-record(subst, { i :: mrdb:iterator()
-record(subst, { i :: mrdb:mrdb_iterator()
, vals_f
, cur
, mref }).
Expand Down Expand Up @@ -121,6 +121,7 @@ iterator_move_bag(#mrdb_ix_iter{i = I, sub = Sub}, Dir) ->
Other
end.

-spec opt_read(mrdb:ref_or_tab(), Key :: any()) -> any().
opt_read(R, Key) ->
case mrdb:read(R, Key, []) of
[Obj] ->
Expand Down
2 changes: 2 additions & 0 deletions src/mrdb_mutex.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

-export([ do/2 ]).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.

%% We use a gen_server-based FIFO queue (one queue per alias) to manage the
%% critical section.
Expand Down

0 comments on commit 296813e

Please sign in to comment.