[Couchdb Wiki] Update of HTTP_view_API by Sebasti anCohnen
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The HTTP_view_API page has been changed by SebastianCohnen. The comment on this change is: fixed: views are only updated/rebuild on access. http://wiki.apache.org/couchdb/HTTP_view_API?action=diffrev1=35rev2=36 -- == Altering/Changing Views == - To change a view or multiple view just alter the design document (see HttpDocumentApi) they are stored in and save it as a new revision. This causes all the views in that design document to be rebuilt. + To change a view or multiple view just alter the design document (see HttpDocumentApi) they are stored in and save it as a new revision. This causes all the views in that design document to be rebuilt on the next access in case the view code has been changed. == Access/Query ==
[Couchdb Wiki] Trivial Update of Introduction_to_Cou chDB_views by SvenHelmberger
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The Introduction_to_CouchDB_views page has been changed by SvenHelmberger. The comment on this change is: 0.11 is no longer trunk. http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views?action=diffrev1=32rev2=33 -- The second parameter of the ''emit()'' function can be ''null''. CouchDB then only stores the [key,docid] in the view. You can use the view as a compact lookup mechanism and fetch the document's details, if needed, in subsequent requests or by adding parameter ''include_docs=true'' === Linked documents === - ''This is a new feature in couchdb trunk / 0.11'' + ''This is a new feature in couchdb 0.11'' If you emit an object value which has '''{'_id': XXX}''' then include_docs will fetch the document with id XXX rather than the document which was processed to emit the key/value pair.
svn commit: r930363 - in /couchdb/trunk: src/couchdb/ test/etap/
Author: damien Date: Fri Apr 2 20:01:11 2010 New Revision: 930363 URL: http://svn.apache.org/viewvc?rev=930363view=rev Log: Deterministic/synchronous shutdown code. Modified: couchdb/trunk/src/couchdb/couch_config.erl couchdb/trunk/src/couchdb/couch_db.erl couchdb/trunk/src/couchdb/couch_db_updater.erl couchdb/trunk/src/couchdb/couch_external_server.erl couchdb/trunk/src/couchdb/couch_file.erl couchdb/trunk/src/couchdb/couch_native_process.erl couchdb/trunk/src/couchdb/couch_os_process.erl couchdb/trunk/src/couchdb/couch_query_servers.erl couchdb/trunk/src/couchdb/couch_ref_counter.erl couchdb/trunk/src/couchdb/couch_server.erl couchdb/trunk/src/couchdb/couch_server_sup.erl couchdb/trunk/src/couchdb/couch_stats_collector.erl couchdb/trunk/src/couchdb/couch_util.erl couchdb/trunk/src/couchdb/couch_view.erl couchdb/trunk/src/couchdb/couch_view_group.erl couchdb/trunk/test/etap/010-file-basics.t couchdb/trunk/test/etap/040-util.t Modified: couchdb/trunk/src/couchdb/couch_config.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_config.erl?rev=930363r1=930362r2=930363view=diff == --- couchdb/trunk/src/couchdb/couch_config.erl (original) +++ couchdb/trunk/src/couchdb/couch_config.erl Fri Apr 2 20:01:11 2010 @@ -111,7 +111,7 @@ terminate(_Reason, _State) - handle_call(all, _From, Config) - Resp = lists:sort((ets:tab2list(?MODULE))), {reply, Resp, Config}; -handle_call({set, Sec, Key, Val, Persist}, _From, Config) - +handle_call({set, Sec, Key, Val, Persist}, From, Config) - true = ets:insert(?MODULE, {{Sec, Key}, Val}), case {Persist, Config#config.write_filename} of {true, undefined} - @@ -121,9 +121,12 @@ handle_call({set, Sec, Key, Val, Persist _ - ok end, -[catch F(Sec, Key, Val, Persist) || {_Pid, F} - Config#config.notify_funs], -{reply, ok, Config}; -handle_call({delete, Sec, Key, Persist}, _From, Config) - +spawn_link(fun() - +[catch F(Sec, Key, Val, Persist) || {_Pid, F} - Config#config.notify_funs], +gen_server:reply(From, ok) +end), +{noreply, Config}; +handle_call({delete, Sec, Key, Persist}, From, Config) - true = ets:delete(?MODULE, {Sec,Key}), case {Persist, Config#config.write_filename} of {true, undefined} - @@ -133,8 +136,11 @@ handle_call({delete, Sec, Key, Persist}, _ - ok end, -[catch F(Sec, Key, deleted, Persist) || {_Pid, F} - Config#config.notify_funs], -{reply, ok, Config}; +spawn_link(fun() - +[catch F(Sec, Key, deleted, Persist) || {_Pid, F} - Config#config.notify_funs], +gen_server:reply(From, ok) +end), +{noreply, Config}; handle_call({register, Fun, Pid}, _From, #config{notify_funs=PidFuns}=Config) - erlang:monitor(process, Pid), % convert 1 and 2 arity to 3 arity Modified: couchdb/trunk/src/couchdb/couch_db.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=930363r1=930362r2=930363view=diff == --- couchdb/trunk/src/couchdb/couch_db.erl (original) +++ couchdb/trunk/src/couchdb/couch_db.erl Fri Apr 2 20:01:11 2010 @@ -915,10 +915,11 @@ init({DbName, Filepath, Fd, Options}) - {ok, #db{fd_ref_counter=RefCntr}=Db} = gen_server:call(UpdaterPid, get_db), couch_ref_counter:add(RefCntr), couch_stats_collector:track_process_count({couchdb, open_databases}), +process_flag(trap_exit, true), {ok, Db}. -terminate(Reason, _Db) - -couch_util:terminate_linked(Reason), +terminate(_Reason, Db) - +couch_util:shutdown_sync(Db#db.update_pid), ok. handle_call({open_ref_count, OpenerPid}, _, #db{fd_ref_counter=RefCntr}=Db) - @@ -946,7 +947,11 @@ handle_cast(Msg, Db) - code_change(_OldVsn, State, _Extra) - {ok, State}. - + +handle_info({'EXIT', _Pid, normal}, Db) - +{noreply, Db}; +handle_info({'EXIT', _Pid, Reason}, Server) - +{stop, Reason, Server}; handle_info(Msg, Db) - ?LOG_ERROR(Bad message received for db ~s: ~p, [Db#db.name, Msg]), exit({error, Msg}). Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=930363r1=930362r2=930363view=diff == --- couchdb/trunk/src/couchdb/couch_db_updater.erl (original) +++ couchdb/trunk/src/couchdb/couch_db_updater.erl Fri Apr 2 20:01:11 2010 @@ -20,6 +20,7 @@ init({MainPid, DbName, Filepath, Fd, Options}) - +process_flag(trap_exit, true), case lists:member(create, Options) of true - % create a new header and writes it to the file @@ -37,8 +38,10 @@ init({MainPid, DbName, Filepath, Fd, Opt {ok, Db2#db{main_pid=MainPid}}.
svn commit: r930365 - /couchdb/trunk/src/couchdb/couch_server.erl
Author: damien Date: Fri Apr 2 20:01:17 2010 New Revision: 930365 URL: http://svn.apache.org/viewvc?rev=930365view=rev Log: change couch_server calls to have infinity timeout, because it might have to wait for disk io. Modified: couchdb/trunk/src/couchdb/couch_server.erl Modified: couchdb/trunk/src/couchdb/couch_server.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server.erl?rev=930365r1=930364r2=930365view=diff == --- couchdb/trunk/src/couchdb/couch_server.erl (original) +++ couchdb/trunk/src/couchdb/couch_server.erl Fri Apr 2 20:01:17 2010 @@ -51,7 +51,7 @@ sup_start_link() - gen_server:start_link({local, couch_server}, couch_server, [], []). open(DbName, Options) - -case gen_server:call(couch_server, {open, DbName, Options}) of +case gen_server:call(couch_server, {open, DbName, Options}, infinity) of {ok, Db} - Ctx = proplists:get_value(user_ctx, Options, #user_ctx{}), {ok, Db#db{user_ctx=Ctx}}; @@ -60,7 +60,7 @@ open(DbName, Options) - end. create(DbName, Options) - -case gen_server:call(couch_server, {create, DbName, Options}) of +case gen_server:call(couch_server, {create, DbName, Options}, infinity) of {ok, Db} - Ctx = proplists:get_value(user_ctx, Options, #user_ctx{}), {ok, Db#db{user_ctx=Ctx}}; @@ -69,7 +69,7 @@ create(DbName, Options) - end. delete(DbName, Options) - -gen_server:call(couch_server, {delete, DbName, Options}). +gen_server:call(couch_server, {delete, DbName, Options}, infinity). check_dbname(#server{dbname_regexp=RegExp}, DbName) - case re:run(DbName, RegExp, [{capture, none}]) of
buildbot success in ASF Buildbot on couchdb-coverage
The Buildbot has detected a restored build of couchdb-coverage on ASF Buildbot. Full details are available at: http://ci.apache.org/builders/couchdb-coverage/builds/265 Buildbot URL: http://ci.apache.org/ Buildslave for this Build: bb-vm_ubuntu Build Reason: Build Source Stamp: [branch couchdb/trunk] 930365 Blamelist: damien Build succeeded! sincerely, -The ASF Buildbot
svn commit: r930430 - in /couchdb/trunk: etc/couchdb/default.ini.tpl.in share/www/script/test/changes.js share/www/script/test/oauth.js share/www/script/test/stats.js src/couchdb/couch_httpd_misc_hand
Author: damien Date: Fri Apr 2 23:17:02 2010 New Revision: 930430 URL: http://svn.apache.org/viewvc?rev=930430view=rev Log: Removed _sleep from all tests. replaced with loops that spin until a condition is true. Makes tests faster and less likely to fail sporadically. Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in couchdb/trunk/share/www/script/test/changes.js couchdb/trunk/share/www/script/test/oauth.js couchdb/trunk/share/www/script/test/stats.js couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=930430r1=930429r2=930430view=diff == --- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original) +++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Fri Apr 2 23:17:02 2010 @@ -65,7 +65,6 @@ _uuids = {couch_httpd_misc_handlers, han _restart = {couch_httpd_misc_handlers, handle_restart_req} _stats = {couch_httpd_stats_handlers, handle_stats_req} _log = {couch_httpd_misc_handlers, handle_log_req} -_sleep = {couch_httpd_misc_handlers, handle_sleep_req} _session = {couch_httpd_auth, handle_session_req} _oauth = {couch_httpd_oauth, handle_oauth_req} Modified: couchdb/trunk/share/www/script/test/changes.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/changes.js?rev=930430r1=930429r2=930430view=diff == --- couchdb/trunk/share/www/script/test/changes.js (original) +++ couchdb/trunk/share/www/script/test/changes.js Fri Apr 2 23:17:02 2010 @@ -70,44 +70,45 @@ couchTests.changes = function(debug) { // WebKit (last checked on nightly #47686) does fail on processing // the async-request properly while javascript is executed. -var sleep = function(msecs) { - // by making a slow sync request, we allow the waiting XHR request data - // to be received. - var req = CouchDB.request(GET, /_sleep?time= + msecs); - T(JSON.parse(req.responseText).ok == true); -} - xhr.open(GET, /test_suite_db/_changes?feed=continuous, true); xhr.send(); var docBar = {_id:bar, bar:1}; db.save(docBar); + +while(true) { + var lines = xhr.responseText.split(\n); + try { + var change1 = JSON.parse(lines[0]); + var change2 = JSON.parse(lines[1]); + break; + } catch (e) {} + db.info() // sync http req allow async req to happen +} -sleep(100); -var lines = xhr.responseText.split(\n); - -var change = JSON.parse(lines[0]); - -T(change.seq == 1) -T(change.id == foo) - -change = JSON.parse(lines[1]); - -T(change.seq == 2) -T(change.id == bar) -T(change.changes[0].rev == docBar._rev) - +T(change1.seq == 1) +T(change1.id == foo) + +T(change2.seq == 2) +T(change2.id == bar) +T(change2.changes[0].rev == docBar._rev) + + var docBaz = {_id:baz, baz:1}; db.save(docBaz); -sleep(100); -var lines = xhr.responseText.split(\n); - -change = JSON.parse(lines[2]); - -T(change.seq == 3); -T(change.id == baz); -T(change.changes[0].rev == docBaz._rev); +while(true) { + var lines = xhr.responseText.split(\n); + try { + var change3 = JSON.parse(lines[2]); + break; + } catch (e) {} + db.info() // sync http req allow async req to happen + +} +T(change3.seq == 3); +T(change3.id == baz); +T(change3.changes[0].rev == docBaz._rev); xhr = CouchDB.newXhr(); @@ -115,10 +116,13 @@ couchTests.changes = function(debug) { //verify the hearbeat newlines are sent xhr.open(GET, /test_suite_db/_changes?feed=continuousheartbeat=10, true); xhr.send(); - -sleep(100); - -var str = xhr.responseText; + +str = xhr.responseText; +while(str.charAt(str.length - 1) != \n || +str.charAt(str.length - 2) != \n) { +db.info() // sync http req allow async req to happen +str = xhr.responseText; +} T(str.charAt(str.length - 1) == \n) T(str.charAt(str.length - 2) == \n) @@ -129,39 +133,48 @@ couchTests.changes = function(debug) { xhr.open(GET, /test_suite_db/_changes?feed=longpoll, true); xhr.send(); - -sleep(100); -var lines = xhr.responseText.split(\n); -T(lines[5]=='last_seq:3}'); - + +while(true) { +try { +var lines = xhr.responseText.split(\n); +if(lines[5]=='last_seq:3}') { +break; +} +} catch (e) {} +db.info(); // sync http req allow async req to happen +} + xhr = CouchDB.newXhr(); xhr.open(GET, /test_suite_db/_changes?feed=longpollsince=3, true); xhr.send(); -sleep(100); - var docBarz = {_id:barz,