Hi! I’m running the following simple query to read from an index:
q.Select(
['data'],
q.Get(q.Match(q.Index('appByHostname'), [appHostname])),
null,
),
Here’s how the index was created:
export default q.CreateIndex({
name: 'appByHostname',
source: q.Collection('apps'),
terms: [
{
field: ['data', 'hostnames'],
},
],
serialized: true,
unique: true,
})
And here’s what a typical app document might contain:
{
id: "some-id",
hostnames: ["some-hostname.com", "some-other-hostname.com"],
}
A few moments ago, the query randomly started failing with the following error:
2022-04-29T00:54:54Z app[c00a0d01] sjc [info]UnknownError: contended transaction
2022-04-29T00:54:54Z app[c00a0d01] sjc [info] at Function.FaunaHTTPError.raiseForStatusCode (https://cdn.skypack.dev/-/faunadb@v4.5.2-3grtqHoapaCgnBEQKCqj/dist=es2019,mode=imports/optimized/faunadb.js:877:15)
2022-04-29T00:54:54Z app[c00a0d01] sjc [info] at Client._handleRequestResult (https://cdn.skypack.dev/-/faunadb@v4.5.2-3grtqHoapaCgnBEQKCqj/dist=es2019,mode=imports/optimized/faunadb.js:3349:25)
2022-04-29T00:54:54Z app[c00a0d01] sjc [info] at https://cdn.skypack.dev/-/faunadb@v4.5.2-3grtqHoapaCgnBEQKCqj/dist=es2019,mode=imports/optimized/faunadb.js:3334:11
2022-04-29T00:54:54Z app[c00a0d01] sjc [info] at async Wrapper.func (file:///app/main.js:242:15)
2022-04-29T00:54:54Z app[c00a0d01] sjc [info] at async Wrapper.wrapFunction (https://cdn.skypack.dev/-/async-cache-dedupe@v1.2.2-UrZ57DlOVSkWziAvXRMv/dist=es2019,mode=imports/optimized/async-cache-dedupe.js:889:20)
This persisted for about a minute and then recovered on its own.
I’m curious what this error means in the context of a read-only query (I’ve seen a few posts about it that involve writes, which doesn’t sound like it would apply here), and, more importantly, what I can do to prevent it from happening in the future.
I have a slight suspicion that it might have something to do with the serialized: true
property of the index, but I haven’t found enough documentation on what it actually does to be sure. The only “explanation” I was able to find was here:
Optional - If
true
, writes to this index are serialized with concurrent reads and writes. The default istrue
.
But as you can see it’s a rather… tautological description and isn’t all that helpful for understanding.
Of course, that suspicion could very well be complete off-base.
Any insights from folks with more expertise would be appreciated. Thanks!