Description
Running the Eventing scriptlet "advancedGetOpWithCache" from the docs and modifying the function to access a document twice we see that on the second call an incorrect meta.id is returned.
// To run configure the settings for this Function, advancedGetOpWithCache, as follows:
|
//
|
// Version 7.1+
|
// "Function Scope"
|
// *.* (or try bulk.data if non-privileged)
|
// Version 7.0.2+
|
// "Listen to Location"
|
// bulk.data.source
|
// "Eventing Storage"
|
// rr100.eventing.metadata
|
// Binding(s)
|
// 1. "binding type", "alias name...", "bucket.scope.collection", "Access"
|
// "bucket alias", "src_col", "bulk.data.source", "read and write"function OnUpdate(doc, meta) {
|
// filter out non-interesting documents
|
if (!doc.type || doc.type !== "test_adv_get") return;
|
log('input doc ', doc);
|
log('input meta', meta);
|
// let's read the same item and then try to read a non existent item
|
var meta_ary = [{"id":"test_adv_get::1"}, {"id":"not_present::1"}];
|
for (var i = 0; i < meta_ary.length; i++) {
|
var result
|
result = couchbase.get(src_col,meta_ary[i],{"cache": true});
|
if (result.success) {
|
log('1 success adv. get with cache: result',result);
|
} else {
|
log('1 failure adv. get with cache: id',meta_ary[i].id,'result',result);
|
}
|
// error occurs on second attempt
|
result = couchbase.get(src_col,meta_ary[i],{"cache": true});
|
if (result.success) {
|
log('2 success adv. get with cache: result',result);
|
} else {
|
log('2 failure adv. get with cache: id',meta_ary[i].id,'result',result);
|
}
|
}
|
}
|
As per the scriptlet instructions make a single document in bulk.data.source with
KEY test_adv_get::1
DATA {"id": 1,"type": "test_adv_get"}
Deploy the function the first call to
result = couchbase.get(src_col,meta_ary[i],{"cache": true});
|
returns the correct meta.id in the result of test_adv_get::1 BUT the second call incorrectly returns bulk as the meta.id
The log file is as follows:
2022-10-08T10:22:57.579-07:00 [INFO] "input doc " {"id":1,"type":"test_adv_get"}
|
2022-10-08T10:22:57.580-07:00 [INFO] "input meta" {"cas":"1665249103316516864","id":"test_adv_get::1","expiration":0,"flags":33554438,"vb":324,"seq":3,"datatype":"json","keyspace":{"bucket_name":"bulk","scope_name":"data","collection_name":"source"},"cid":8}
|
2022-10-08T10:22:57.581-07:00 [INFO] "1 success adv. get with cache: result" {"doc":{"id":1,"type":"test_adv_get"},"meta":{"id":"test_adv_get::1","cas":"1665249103316516864","datatype":"json"},"success":true}
|
2022-10-08T10:22:57.581-07:00 [INFO] "2 success adv. get with cache: result" {"doc":{"id":1,"type":"test_adv_get"},"meta":{"id":"bulk","cas":"1665249103316516864","datatype":"json"},"success":true}
|
2022-10-08T10:22:57.582-07:00 [INFO] "1 failure adv. get with cache: id" "not_present::1" "result" {"error":{"code":1,"name":"LCB_KEY_ENOENT","desc":"The document key does not exist on the server","key_not_found":true},"success":false}
|
2022-10-08T10:22:57.582-07:00 [INFO] "2 failure adv. get with cache: id" "not_present::1" "result" {"error":{"code":1,"name":"LCB_KEY_ENOENT","desc":"The document key does not exist on the server","key_not_found":true},"success":false}
|
Note for KEY test_adv_get::1 (which exists) meta.id is correct as "test_adv_get::1" for the first call, BUT it is incorrect for the second call is is wrong returning as "bulk" (somehow it returns a component of the keyspace?)
Note if we set {"cache": false} (or remove the option) it doesn't do bucket backed caching and the returned meta.id is always correct:
2022-10-08T10:31:59.484-07:00 [INFO] "input doc " {"id":1,"type":"test_adv_get"}
|
2022-10-08T10:31:59.485-07:00 [INFO] "input meta" {"cas":"1665249103316516864","id":"test_adv_get::1","expiration":0,"flags":33554438,"vb":324,"seq":3,"datatype":"json","keyspace":{"bucket_name":"bulk","scope_name":"data","collection_name":"source"},"cid":8}
|
2022-10-08T10:31:59.487-07:00 [INFO] "1 success adv. get with cache: result" {"doc":{"id":1,"type":"test_adv_get"},"meta":{"id":"test_adv_get::1","cas":"1665249103316516864","datatype":"json"},"success":true}
|
2022-10-08T10:31:59.488-07:00 [INFO] "2 success adv. get with cache: result" {"doc":{"id":1,"type":"test_adv_get"},"meta":{"id":"test_adv_get::1","cas":"1665249103316516864","datatype":"json"},"success":true}
|
2022-10-08T10:31:59.488-07:00 [INFO] "1 failure adv. get with cache: id" "not_present::1" "result" {"error":{"code":1,"name":"LCB_KEY_ENOENT","desc":"The document key does not exist on the server","key_not_found":true},"success":false}
|
2022-10-08T10:31:59.489-07:00 [INFO] "2 failure adv. get with cache: id" "not_present::1" "result" {"error":{"code":1,"name":"LCB_KEY_ENOENT","desc":"The document key does not exist on the server","key_not_found":true},"success":false}
|
Attachments
Issue Links
- backports to
-
MB-54315 [BP to 7.2.0] bucket backed cache returns wrong meta.id on calls 2-N if cached.
- Closed