-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Couch index fixes #4491
Couch index fixes #4491
Conversation
c81c5c5
to
84b1ed5
Compare
84b1ed5
to
aca3bc2
Compare
a4f9267
to
8bf45ad
Compare
fun(DbShard) -> | ||
lists:foreach( | ||
fun({_DbShard, {_DDocId, Sig}}) -> | ||
% check if there are other ddocs with the same Sig for the same db | ||
SigDDocs = ets:match_object(St#st.by_db, {DbShard, {'$1', Sig}}), | ||
if | ||
length(SigDDocs) > 1 -> | ||
% remove records from by_db for this DDoc | ||
Args = [DbShard, DDocId, Sig], | ||
gen_server:cast(St#st.server_name, {rem_from_ets, Args}); | ||
true -> | ||
% single DDoc with this Sig - close couch_index processes | ||
case ets:lookup(St#st.by_sig, {DbShard, Sig}) of | ||
[{_, IndexPid}] -> | ||
(catch gen_server:cast( | ||
IndexPid, {ddoc_updated, DDocResult} | ||
)); | ||
[] -> | ||
[] | ||
end | ||
end | ||
end, | ||
ets:match_object(St#st.by_db, {DbShard, {DDocId, '$1'}}) | ||
) | ||
end, | ||
DbShards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid deep nesting a utility function might work better shard_ddoc_updated(DbShard, St)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is existing code, I'd rather not alter beyond what's essential.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, nesting is a bit deep and a helper would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your diff will be smaller if you don't indent silly goose.
8bf45ad
to
2220d6b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor changes, mostly biggest around checking the wrong pids in the openers table.
fun(DbShard) -> | ||
lists:foreach( | ||
fun({_DbShard, {_DDocId, Sig}}) -> | ||
% check if there are other ddocs with the same Sig for the same db | ||
SigDDocs = ets:match_object(St#st.by_db, {DbShard, {'$1', Sig}}), | ||
if | ||
length(SigDDocs) > 1 -> | ||
% remove records from by_db for this DDoc | ||
Args = [DbShard, DDocId, Sig], | ||
gen_server:cast(St#st.server_name, {rem_from_ets, Args}); | ||
true -> | ||
% single DDoc with this Sig - close couch_index processes | ||
case ets:lookup(St#st.by_sig, {DbShard, Sig}) of | ||
[{_, IndexPid}] -> | ||
(catch gen_server:cast( | ||
IndexPid, {ddoc_updated, DDocResult} | ||
)); | ||
[] -> | ||
[] | ||
end | ||
end | ||
end, | ||
ets:match_object(St#st.by_db, {DbShard, {DDocId, '$1'}}) | ||
) | ||
end, | ||
DbShards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, nesting is a bit deep and a helper would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
813cae1
to
4526b17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few eunit tests are failing
module 'couch_index_ddoc_updated_tests'
Check ddoc update actions
couch_index_ddoc_updated_tests:54: check_all_indexers_exit_on_ddoc_change...*failed*
in function couch_index_server:handle_db_event/3 (src/couch_index_server.erl, line 388)
in call from lists:foreach/2 (lists.erl, line 1342)
in call from couch_index_ddoc_updated_tests:'-check_all_indexers_exit_on_ddoc_change/1-fun-7-'/1 (test/eunit/couch_index_ddoc_updated_tests.erl, line 106)
in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
in call from eunit_proc:run_test/1 (eunit_proc.erl, line 531)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 356)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 514)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 456)
**error:{badrecord,st}
output:<<"">>
Would probably be good to have eunit tests exercising some of the new code. One approach there could be to mock couch_index_server and intercept the async opener logic to force it crash.
4526b17
to
224d676
Compare
@rnewson forgot to add unit tests #4491 (review) |
Previously we didin't always reply to waiting `get_index` calls as sometimes we clobbered or deleted waiters in by_sig ets table. Ref: #4491
Previously we didin't always reply to waiting `get_index` calls as sometimes we clobbered or deleted waiters in by_sig ets table. Ref: #4491
Previously we didin't always reply to waiting `get_index` calls as sometimes we clobbered or deleted waiters in by_sig ets table. Ref: #4491
Previously we didin't always reply to waiting `get_index` calls as sometimes we clobbered or deleted waiters in by_sig ets table. Ref: #4491
Previously we didin't always reply to waiting `get_index` calls as sometimes we clobbered or deleted waiters in by_sig ets table. Ref: #4491
Previously we didin't always reply to waiting `get_index` calls as sometimes we clobbered or deleted waiters in by_sig ets table. Ref: #4491
couch_index_server can crash if;
This PR improves behaviour as follows;