Oracle Text error when performing JSON API query
See original GitHub issueAffected Daml version
2.3.4 (previous ones were not tested)
Bug description
If the JSON API Server is being run with an Oracle query store, query on text field of the payload either results in 501 response, or returns an empty response. The query looks like the following:
{
"templateIds": [
"b0a685079d389146932b97f0556332083c4053612359518aeea1452c1d45e8a5:SIS.Main.SIRequest:SIRequest"
],
"query": {
"si_detail": {
"si_input_no": {
"%gt": ""
}
}
}
}
When the failure happens, the response is:
{"result":[],"errors":["Endpoints.ServerError: internal server error"],"status":501}
DEBUG level log:
12-09-2022 13:35:22.485 [http-json-ledger-api-akka.actor.default-dispatcher-15] ERROR com.daml.http.dbbackend.ContractDao - Failed Statement Execution:
SELECT c.contract_id contract_id, cst.tpid template_id, key, key_hash, payload,
signatories, observers, agreement_text
FROM jsonapi_contract c
JOIN jsonapi_contract_stakeholders cst ON (c.contract_id = cst.contract_id)
WHERE (cst.stakeholder IN (?) )
AND ((? = cst.tpid AND (JSON_EXISTS(payload, '$."si_detail"."si_input_no"?(@ > $X)' PASSING ? AS X) AND JSON_EXISTS(payload, '$."si_detail"?(@ != null)'))) )
arguments = [sandbox::1220b7a3cae8679a7313f704f5ce62bceed5e637d69db8f2270cf3343d8fe50228c6, 1, ]
elapsed = 210 ms exec (failed)
failure = ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 22
To reproduce
Start a sandbox. Startup a JSON API Service with Oracle query store. Create a contract of this template:
module SIS.Main.SIRequest where
import Daml.Script
data SIDetail = SIDetail with
si_input_no : Text
deriving (Eq, Show)
template SIRequest
with
requester : Party
si_detail : SIDetail
where
signatory requester
Query on /v1/query using this payload:
{
"templateIds": [
"SIS.Main.SIRequest:SIRequest"
],
"query": {
"si_detail": {
"si_input_no": {
"%gt": ""
}
}
}
}
The error seem to occur more reliably when multiple parties are allocated and a token with an act_as claim with all is used.
Expected behavior
Expected not to fail, also when not failing to return all contracts with non-empty si_input_no, like with a postgres query store, or without a query store.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I could not reproduce the error when a the
disableContractPayloadIndexing=true
is used at DB init. Although the result set is still empty.Using an empty string should not matter, and it does not. I have tested it extensively. The same query against the JSON API server without a query store or against a PostgreSQL query store, returns appropriate results (interpreting the %gt as standard lexicographic ordering would govern it).
#15022 should address the empty results when
disableContractPayloadIndexing=true
. It does not help with theOracle Text error
when the index is enabled.