Skip to content
This repository
Browse code

Merge pull request #175 from basho/az655-osync-warning

Az655 osync warning
  • Loading branch information...
commit 6a29591ecd9da73e27223a1a55acd80c21d4d17f 2 parents 15a19a5 + 31cc4c9
Jeffrey Massung authored September 07, 2011

Showing 1 changed file with 20 additions and 0 deletions. Show diff stats Hide diff stats

  1. 20  src/riak_kv_bitcask_backend.erl
20  src/riak_kv_bitcask_backend.erl
@@ -91,6 +91,7 @@ start(Partition, Config) ->
91 91
                     BitcaskOpts = set_mode(read_write, Config),
92 92
                     case bitcask:open(filename:join(DataRoot, DataFile), BitcaskOpts) of
93 93
                         Ref when is_reference(Ref) ->
  94
+                            check_fcntl(),
94 95
                             schedule_merge(Ref),
95 96
                             maybe_schedule_sync(Ref),
96 97
                             AsyncFolds = config_value(async_folds, Config, true),
@@ -368,6 +369,25 @@ key_counts(RootDir) ->
368 369
 %% ===================================================================
369 370
 
370 371
 %% @private
  372
+%% On linux there is a kernel bug that won't allow fcntl to add O_SYNC
  373
+%% to an already open file descriptor.
  374
+check_fcntl() ->
  375
+    Logged=application:get_env(riak_kv,o_sync_warning_logged),
  376
+    Strategy=application:get_env(bitcask,sync_strategy),
  377
+    case {Logged,Strategy} of
  378
+        {undefined,{ok,o_sync}} ->
  379
+            case riak_core_util:is_arch(linux) of
  380
+                true ->
  381
+                    lager:warning("{sync_strategy,o_sync} not implemented on Linux"),
  382
+                    application:set_env(riak_kv,o_sync_warning_logged,true);
  383
+                _ ->
  384
+                    ok
  385
+            end;
  386
+        _ ->
  387
+            ok
  388
+    end.
  389
+
  390
+%% @private
371 391
 %% Return a function to fold over the buckets on this backend
372 392
 fold_buckets_fun(FoldBucketsFun) ->
373 393
     fun(#bitcask_entry{key=BK}, {Acc, BucketSet}) ->

0 notes on commit 6a29591

Please sign in to comment.
Something went wrong with that request. Please try again.