however when I use a N1QL query to get the expiry I can see that it is still set to zero:
var query = $"SELECT meta() FROM{_settings.PaymentStateBucketName}AS f WHERE f.Identifier = '{identifier}'"; var result = await _paymentStateBucket.QueryAsync<dynamic>(query);
Container seems unlikely, but could you list which ports you’ve exposed (assuming that the .NET program is running outside of the container).
Also, would you mind examining the result of the execute? There may be error/exception information in there. Would you also try it without CAS, and see if that works (that might give us a hint to the nature of the issue)?
Finally, do you think you could try to make a minimum reproducible example? In my example, I didn’t follow exactly what you did, because I don’t have all the details of PaymentStateDocument, _settings, etc. Could you try to see if you can reproduce this behavior with simple literals, just so we can narrow down the issue?
it seems this is a bug whereby the expiration always is returned as 0 but it does not actually affect the document being deleted at the correct time,
considering the previous point I still have put a small solution together complete with docker compose file that replicates this behaviour, hope this helps.
Based on your code, this appears to be an issue with N1QL queries that return expiration and is not a problem with the .NET SDK itself. In your test, your mutation DOES correctly set the expiration (you can see this by browsing to the document in the Couchbase UI).
However, your automated test is trying to verify by using SELECT meta().expiration, which does not return the expiration unless there is a covering index. Please see MB-25493 for more information about this. There are a couple of workarounds there.
For instance, I made your test pass by changing your GetExpirationOfDocument method:
public async Task<ulong> GetExpirationOfDocument(Guid identifier)
{
var query = $"SELECT meta().expiration FROM `bucket` AS f LET v = meta().xattrs.`$document` WHERE f.Identifier = '{identifier}'";
var result = await _bucket.QueryAsync<dynamic>(query);
var expiration = result.Rows.FirstOrDefault()?.expiration;
return expiration;
}
Another option is to create a covering index (as spelled out in MB-25493.
I hope this helps. If none of the workarounds in that ticket are satisfactory, I’d recommend starting a new topic in the N1QL forum.