How it works? time script, worker and tigger in couchbase inside event function as shown in screenshot ? could you show me?

I’m using CB6.5

First, I see you have three active Eventing handlers (by default each handler starts three workers and each workers has two threads). On your 4 core machine you are currently running 15 workers for Eventing that’s 30 threads - that’s why you are seeing the warning message (bottom left of your image). Eventing is a compute oriented service adding workers in excess of your compute capability will actually slow you down.

Next, I’m not entirely sure just what you are asking (you only show a picture with a System log level drop-down). The drop down only impacts the System log in the file system called “eventing.log” this has nothing to do with log(…) statements in your Eventing handler.

Until you clarify your question I would recommend that you walk through the examples at https://docs.couchbase.com/server/6.5/eventing/eventing-examples.html

Also look at https://docs.couchbase.com/server/6.5/eventing/eventing-debugging-and-diagnosability.html#logging-functions for details on logging.

If you are trying to “time” your script - remember your logic is run ‘fresh’ on every mutation but it is possible via log(…) statements in your handler (note there is no logging level here for an individual handler).

As an example I’ll include a “toy” OnUpdate handler with just one worker and a source bucket of travel-sample and no bindings.

You can see these (per handler logs) by selecting the “Log” hyperlink in the Eventing page of the UI once you deploy a the handler on your system.

// sleep time expects milliseconds, this is a busy sleep, just for emulation
function sleepMs (millis) {
    var begDate = new Date();
    var curDate = null;
    do { curDate = new Date(); }  // bad a busy spin ...
    while(curDate - begDate < millis);
}

function OnUpdate(doc, meta) {
    // get time in millis.
    var t1 = new Date().getTime();
    if ( doc.type != "airport" ) {
        var t2 = new Date().getTime();
        var dura = t2 - t1;
        log('skipping non-airport filter took '+dura+'ms., docId', meta.id);        
        return;
    }
    
    // =================================================================
    // do expensive processing here we just emulate something that takes 85 ms.
    // in the real world this might be N1QL or cURL calls.
    sleepMs(85);
    // =================================================================
    
    // get time in millis.
    var t2 = new Date().getTime();
    var dura = t2 - t1;
    log('processed airport for all filter and processing took '+dura+'ms., docId', meta.id);
}

Assuming you set up your Eventing function against the sample data set “travel-sample” and deploy the function should end up with 31,591 lines with either of two forms.

2020-02-18T12:15:20.997-08:00 [INFO] "skipping non-airport filter took 0ms., docId" "route_63520"
2020-02-18T12:15:20.396-08:00 [INFO] "processed airport filter and processing took 85ms., docId" "airport_6720"

The point here is that Eventing is fast but of course once you start executing N1QL statements or performing cURL operations in your Eventing handler you might want to actually time what is going on.

If indeed you are looking at trying to “time” the overall Eventing performance across multiple mutations you might be better off just looking at the graphs in the UI via Servers > Statistics and then expanding the “Eventing Stats: name_of_your_deployed_function” to expose the performance graphs.

Thanks a lot **Jon Strabala **

I understood, and my doubt is clear how script timeout , worker and tiger are working. But I’m still stuff about error and warning inside log level of event function.

My second question is that how cascade delete work? I try whatever given in documentation link:- https://docs.couchbase.com/server/6.5/eventing/eventing-examples-cascade-delete.html

I debug line by line code all code are running properly except DELETE, I found that DELETE query is not working

thanks a lot

Ramjan

I’ll just walked through the version 6.5 cascade delete example using cut-n-paste and verified the complete example works as expected.

You use the term “debug line by line” were you running it in the JavaScript debugger? or do you mean you tried to step through the example. Note both steps 8 (via a trash can) and step 11 (via N1QL) perform a delete. Now you say the delete query is not working - as such I assume you are talking about step 11 I assume you had an issue on:

DELETE FROM users

please provide the output of the following:

SELECT count(*) FROM users
SELECT count(*) FROM transactions
SELECT * FROM transactions

And I will discuss the results with you

Note, I assume you are running 6.5 GA, but please let me know what version of Couchbase you are running. You can do this by selecting the Dashboard in the UI (look at the upper right) and also what OS you are using.

Couchbase severtion is 6.5.0 and OS is Mac