Skip to content

Commit

Permalink
Merge pull request #24 from apache/add-reshard-ioq-priority
Browse files Browse the repository at this point in the history
Add a proper reshard ioq class
  • Loading branch information
nickva authored Nov 18, 2022
2 parents 6abecf9 + 33e8402 commit 961a5c8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/ioq.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
{other, 1.0},
{interactive, 1.0},
{system, 1.0},
{search, 1.0}
{search, 1.0},
{reshard, 0.001}
]).


Expand Down Expand Up @@ -72,6 +73,7 @@
| system
| search
| internal_repl
| reshard
| other
| customer
| db_meta
Expand Down
2 changes: 2 additions & 0 deletions operator_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ that the mapping of IOQ classes to class priorities is not 1:1.
| internal_repl | replication | IO requests related to internal |
| | | replication. |
| | | |
| reshard | reshard | IO requests related to resharding jobs |
| | | |
| low | low | IO requests related to requests made by |
| | | users via the http layer where the |
| | | "x-cloudant-priority: low" header is set. |
Expand Down
12 changes: 12 additions & 0 deletions priv/stats_descriptions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
{type, counter},
{desc, <<"IO related to internal system activities">>}
]}.
{[couchdb, io_queue, reshard], [
{type, counter},
{desc, <<"IO related to resharding jobs">>}
]}.
{[couchdb, io_queue, other], [
{type, counter},
{desc, <<"IO related to internal replication">>}
Expand Down Expand Up @@ -126,6 +130,10 @@
{type, counter},
{desc, <<"bypassed IO related to internal system activities">>}
]}.
{[couchdb, io_queue_bypassed, reshard], [
{type, counter},
{desc, <<"bypassed IO related to resharding jobs">>}
]}.
{[couchdb, io_queue_bypassed, other], [
{type, counter},
{desc, <<"bypassed IO related to internal replication">>}
Expand Down Expand Up @@ -214,6 +222,10 @@
{type, counter},
{desc, <<"IO related to internal system activities">>}
]}.
{[couchdb, io_queue2, reshard, count], [
{type, counter},
{desc, <<"IO related to resharding jobs">>}
]}.
{[couchdb, io_queue2, other, count], [
{type, counter},
{desc, <<"IO related to internal replication">>}
Expand Down
6 changes: 6 additions & 0 deletions src/ioq_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ analyze_priority({view_compact, _Shard, _GroupId}) ->
{view_compact, nil};
analyze_priority({internal_repl, _Shard}) ->
{internal_repl, nil};
analyze_priority({reshard, _Shard}) ->
{reshard, nil};
analyze_priority({system, _Shard}) ->
{system, nil};
analyze_priority({low, _Shard}) ->
Expand Down Expand Up @@ -257,6 +259,8 @@ enqueue_request(#request{class = view_compact} = Req, State) ->
State#state{qC = update_queue(Req, State#state.qC, State#state.dedupe)};
enqueue_request(#request{class = internal_repl} = Req, State) ->
State#state{qR = update_queue(Req, State#state.qR, State#state.dedupe)};
enqueue_request(#request{class = reshard} = Req, State) ->
State#state{qR = update_queue(Req, State#state.qR, State#state.dedupe)};
enqueue_request(#request{class = low} = Req, State) ->
State#state{qL = update_queue(Req, State#state.qL, State#state.dedupe)};
enqueue_request(Req, State) ->
Expand Down Expand Up @@ -473,6 +477,8 @@ make_key(interactive, {append_bin, _}) ->
<<"writes">>;
make_key(system, _) ->
<<"system">>;
make_key(reshard, _) ->
<<"reshard">>;
make_key(search, _) ->
<<"search">>;
make_key(_, _) ->
Expand Down
5 changes: 3 additions & 2 deletions src/ioq_server2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ queue_depths_test_() ->
#ioq_request{user=Foo, class=view_update},
#ioq_request{user=Foo, class=view_update},
#ioq_request{user=Foo, class=view_update},
#ioq_request{user=Foo, class=reshard},

#ioq_request{user=Bar, class=interactive},
#ioq_request{user=Bar, class=db_update},
Expand All @@ -788,7 +789,7 @@ queue_depths_test_() ->
{replication, 3},
{low, 1},
{channels, {[
{<<"foo">>, [2,1,4]},
{<<"foo">>, [3,1,4]},
{<<"bar">>, [1,3,1]}
]}}
],
Expand Down Expand Up @@ -1028,7 +1029,7 @@ check_call(Server, Call, Priority) ->


io_classes() -> [interactive, view_update, db_compact, view_compact,
internal_repl, other, db_meta].
internal_repl, other, db_meta, reshard].


shards() ->
Expand Down
2 changes: 1 addition & 1 deletion test/ioq_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ check_call(Server, Call, Priority) ->
?_assertEqual({reply, Call}, ioq:call(Server, Call, Priority)).

io_classes() -> [interactive, view_update, db_compact, view_compact,
internal_repl, other, search, system].
internal_repl, other, search, system, reshard].

shards() ->
[
Expand Down

0 comments on commit 961a5c8

Please sign in to comment.