Skip to content

Commit 0e0bb1e

Browse files
committed
Switch from 'error_logger' to 'logger'
Includes changes on the `openriak-3.2` branch. wday-contrib 2325
2 parents 9a965a5 + 1fcc4fb commit 0e0bb1e

8 files changed

Lines changed: 54 additions & 37 deletions

File tree

.github/workflows/erlang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
rebar: ['3.20', '3.22']
2222

2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v4
2525
- uses: erlef/setup-beam@v1
2626
with:
2727
otp-version: ${{ matrix.otp }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Bitcask - A Log-Structured Hash Table for Fast Key/Value Data
22

3-
[![Build Status](https://github.com/basho/bitcask/workflows/erlang.yml/badge.svg)](https://github.com/basho/bitcask/actions)
3+
[![Build Status](https://github.com/OpenRiak/bitcask/actions/workflows/erlang.yml/badge.svg)](https://github.com/OpenRiak/bitcask/actions/workflows/erlang.yml)
44

5-
Bitcask requires [Erlang/OTP](https://erlang.org) 22+ and [Rebar3](https://rebar3.org) in your `$PATH`.
5+
Bitcask requires [Erlang/OTP](https://erlang.org) 24+ and [Rebar3](https://rebar3.org) in your `$PATH`.
66

77
The included [Makefile](Makefile) wraps most common Rebar3 build operations.

eqc/bitcask_qc_expiry.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
-include_lib("eqc/include/eqc.hrl").
2727
-include_lib("eunit/include/eunit.hrl").
2828
-include("include/bitcask.hrl").
29-
-include("stacktrace.hrl").
3029

3130
-compile([export_all, nowarn_export_all]).
3231

32+
-ifdef(OTP_RELEASE). %% This implies 21 or higher
33+
-define(_exception_(Class, Reason, StackToken), Class:Reason:StackToken).
34+
-define(_get_stacktrace_(StackToken), StackToken).
35+
-else.
36+
-define(_exception_(Class, Reason, _), Class:Reason).
37+
-define(_get_stacktrace_(_), erlang:get_stacktrace()).
38+
-endif.
39+
3340
keys() ->
3441
eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
3542

rebar.config

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,21 @@
7070
{app_default, "http://www.erlang.org/doc/man"},
7171
{preprocess, true},
7272
{macros, [
73-
{'EDOC', true},
74-
{'BASHO_DOCS', true}
73+
{'EDOC', true}
7574
]}
7675
]}
7776
]},
7877
{prod, [
7978
{erl_opts, [
80-
warnings_as_errors,
81-
{d, 'BASHO_PROD'}
79+
warnings_as_errors
8280
]}
8381
]},
8482
% Builds the NIF library with debug output, otherwise same as 'prod'.
8583
% Note that the name of the NIF library is unchanged, so it will appear
8684
% up-to-date for any profile.
8785
{debug, [
8886
{erl_opts, [
89-
warnings_as_errors,
90-
{d, 'BASHO_PROD'}
87+
warnings_as_errors
9188
]},
9289
{port_env, [
9390
{"CFLAGS", "$CFLAGS -DBITCASK_DEBUG"}
@@ -152,8 +149,7 @@
152149
nowarn_export_all,
153150
nowarn_unused_function,
154151
nowarn_unused_import, % EQC
155-
warnings_as_errors,
156-
{d, 'BASHO_TEST'}
152+
warnings_as_errors
157153
]},
158154
{deps, [
159155
{meck, "0.9.2"},

src/bitcask.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{application, bitcask, [
22
{description, "Yet another key/value storage engine"},
3-
{vsn, "2.1.0.4"},
3+
{vsn, "2.1.0.5"},
44
{modules, []},
55
{registered, []},
66
{applications, [kernel, stdlib]},

src/bitcask.erl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%% -------------------------------------------------------------------
22
%%
33
%% Copyright (c) 2010-2017 Basho Technologies, Inc.
4-
%% Copyright (c) 2018-2024 Workday, Inc.
4+
%% Copyright (c) 2018-2025 Workday, Inc.
55
%%
66
%% This file is provided to you under the Apache License,
77
%% Version 2.0 (the "License"); you may not use this file
@@ -95,7 +95,7 @@
9595
%% This atom is the signal that it failed but is harmless in this situation.
9696
-define(POLL_FOR_MERGE_LOCK_PSEUDOFAILURE, pseudo_failure).
9797

98-
%% @type bc_state().
98+
%% Type bc_state().
9999
-record(bc_state, {dirname :: string(),
100100
write_file :: 'fresh' | 'undefined' | #filestate{}, % File for writing
101101
write_lock :: 'undefined' | reference(), % Reference to write lock
@@ -168,9 +168,9 @@ open(Dirname, Opts) ->
168168
ok;
169169
not_stale ->
170170
?LOG_ERROR(
171-
"Attempted to obtain the Bitcask write lock for '~ts' but"
172-
" another Bitcask DB has the lock! Continuing but all"
173-
" write operations will fail.", [Dirname])
171+
"Attempted to obtain the Bitcask write lock for '~ts'"
172+
" but another Bitcask DB has the lock! Continuing but"
173+
" all write operations will fail.", [Dirname])
174174
end,
175175
fresh;
176176
false ->
@@ -2190,9 +2190,16 @@ roundtrip_test_() ->
21902190
{timeout, 60, fun roundtrip_test2/0}.
21912191

21922192
setup_testfolder(Path) ->
2193-
DN = filename:join(?TEST_FILEPATH, Path),
2194-
os:cmd("rm -rf " ++ DN),
2195-
DN.
2193+
Target = filename:join(?TEST_FILEPATH, Path),
2194+
case filelib:is_file(Target) of
2195+
true ->
2196+
?assertMatch(ok, file:del_dir_r(Target), Target),
2197+
?assertMatch(ok, file:make_dir(Target), Target);
2198+
_ ->
2199+
Dummy = filename:join(Target, "dummy"),
2200+
?assertMatch(ok, filelib:ensure_dir(Dummy), Dummy)
2201+
end,
2202+
Target.
21962203

21972204
roundtrip_test2() ->
21982205
FN = setup_testfolder("bc.test.roundtrip"),

src/bitcask_nifs.erl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161
file_seekbof/1,
6262
file_truncate/1
6363
]).
64-
-ifdef(BASHO_CHECK).
65-
%% Dialyzer and XRef won't recognize 'on_load' as using the function and
66-
%% will complain about it.
67-
-export([init_nif_lib/0]).
68-
-endif.
6964

7065
%% Make sure only a consistent set of test macros are defined so we don't
7166
%% have to keep checking them all repeatedly.

test/bitcask_lockops_tests.erl

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%% -------------------------------------------------------------------
22
%%
3-
%% Copyright (c) 2018-2022 Workday, Inc.
3+
%% Copyright (c) 2018-2025 Workday, Inc.
44
%%
55
%% This file is provided to you under the Apache License,
66
%% Version 2.0 (the "License"); you may not use this file
@@ -19,21 +19,28 @@
1919
%% -------------------------------------------------------------------
2020
-module(bitcask_lockops_tests).
2121

22+
%% Warning: Without 'export_all', the first test will fail (that is, it
23+
%% succeeds in acquiring the lock on the second call). This happens even if
24+
%% the tests and external-vm functions are explicitly exported. Clearly
25+
%% something funky is going on in eunit.hrl.
26+
-compile([export_all, nowarn_export_all]).
27+
28+
%% Comment this out to see output from the spawned process.
29+
-define(NODEBUG, true).
30+
2231
-include_lib("eunit/include/eunit.hrl").
2332
-include("bitcask.hrl").
2433

25-
-compile([export_all, nowarn_export_all]).
26-
2734
lock_cannot_be_obtained_on_already_locked_file_within_same_os_process_test() ->
28-
Dir = bitcask:create_test_dir(),
35+
Dir = create_test_dir(?FUNCTION_NAME),
2936
Filename = bitcask_lockops:lock_filename(write,Dir),
3037
ok = file_delete(Filename),
3138
ok = file:write_file(Filename, ""),
3239
{ok, _Lock} = bitcask_lockops:acquire(write, Dir),
3340
?assertMatch({error, locked}, bitcask_lockops:acquire(write, Dir)).
3441

3542
lock_can_be_obtained_on_already_locked_file_is_unlocked_test() ->
36-
Dir = bitcask:create_test_dir(),
43+
Dir = create_test_dir(?FUNCTION_NAME),
3744
Filename = bitcask_lockops:lock_filename(write,Dir),
3845
ok = file_delete(Filename),
3946
ok = file:write_file(Filename, ""),
@@ -42,17 +49,18 @@ lock_can_be_obtained_on_already_locked_file_is_unlocked_test() ->
4249
?assertMatch({ok, _}, bitcask_lockops:acquire(write, Dir)).
4350

4451
lock_cannot_be_obtained_on_already_locked_file_across_os_process_test() ->
45-
DbDir = filename:absname(bitcask:create_test_dir()),
52+
DbDir = filename:absname(create_test_dir(?FUNCTION_NAME)),
4653
%% start another erlang vm that will open the DB and obtain a write
4754
%% lock, then, when we try to obtain a write lock on the current vm
4855
%% it should fail.
56+
%% ToDo: Post OTP 24 use the 'peer' module, too much hassle before then.
4957
{?MODULE, _, TBeam} = code:get_object_code(?MODULE),
5058
{bitcask, _, BBeam} = code:get_object_code(bitcask),
5159
Tbin = filename:dirname(TBeam),
5260
Bbin = filename:dirname(BBeam),
5361
Erl = filename:join([code:root_dir(), "bin", "erl"]),
5462
Cmd = lists:flatten([
55-
Erl, " -pa ", Bbin, " -pa ", Tbin, " -noinput -noshell -eval"
63+
"'", Erl, "' -pa '", Bbin, "' -pa '", Tbin, "' -noinput -noshell -eval"
5664
" 'bitcask_lockops_tests:bitcask_locker_vm_main(\"", DbDir, "\").'"
5765
]),
5866
?debugFmt("~n= COMMAND: ~ts", [Cmd]),
@@ -62,13 +70,13 @@ lock_cannot_be_obtained_on_already_locked_file_across_os_process_test() ->
6270
DB = bitcask:open(DbDir, [read_write]),
6371
?assertMatch({error, {error, locked}}, bitcask:put(DB, <<"k">>, <<"v">>)),
6472
receive
65-
{'DOWN', MonRef, _Type, _Object, _Info} = Msg ->
66-
?debugFmt("~n= RECEIVE: ~0tp", [Msg])
73+
{'DOWN', MonRef, _Type, _Object, _Info} = _Msg ->
74+
?debugFmt("~n= RECEIVE: ~p~n", [_Msg])
6775
end.
6876

6977
run_vm_process(Command) ->
70-
Output = ?cmd(Command),
71-
?debugFmt("~n= OUTPUT ~0tp: ~ts", [erlang:self(), Output]).
78+
_Output = ?cmd(Command),
79+
?debugFmt("~n= CMD OUTPUT: ~s~n", [_Output]).
7280

7381
%% entry function for another vm to lock a bitcask DB
7482
bitcask_locker_vm_main(DbDir) ->
@@ -91,3 +99,7 @@ file_delete(Filename) ->
9199
ok
92100
end.
93101

102+
-spec create_test_dir(Label :: atom() | string()) -> string().
103+
%% Creates a new, empty, directory for testing.
104+
create_test_dir(Label) ->
105+
bitcask:setup_testfolder(io_lib:format("bc.lockops.~s", [Label])).

0 commit comments

Comments
 (0)