Skip to content

Commit 34ac008

Browse files
committed
Fix run_on_first_node scanner features
`run_on_first_node` feature is a running mode for plugins which are only interested in design documents, and may want to avoid fetching clustered design docs on all nodes. However that feature didn't work since it clashed with a premature optimization in plugin's `scan_db/2` function, which avoided scanning the db if no shards were scheduled to be scanned on the first node. For example, with a 3 node cluster and a q=2 db, it was possible to have both of its shards scheduled to be scanned on db2 and db3, respectively, while the plugin was running on db1 only. In that case the plugin would have skipped calling the main part of `scan_db` which does ddoc processing. The fix is to remove the premature optimization and load the ddoc even if no shards are scheduled to be scanned on that node since we may be dealing with a plugin which is only interested in design documents.
1 parent b5dfe12 commit 34ac008

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/couch_scanner/src/couch_scanner_plugin.erl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,7 @@ scan_dbs_fold(#full_doc_info{} = FDI, #st{shards_db = Db} = Acc) ->
315315
{ok, Acc2}
316316
end.
317317

318-
scan_db([], #st{} = St) ->
319-
{ok, St};
320-
scan_db([_ | _] = Shards, #st{} = St) ->
318+
scan_db(Shards, #st{} = St) ->
321319
#st{dbname = DbName, callbacks = Cbks, pst = PSt, skip_dbs = Skip} = St,
322320
#{db := DbCbk} = Cbks,
323321
case match_skip_pat(DbName, Skip) of

0 commit comments

Comments
 (0)