question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Oracle Text error when performing JSON API query

See original GitHub issue

Affected 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:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
matevarga-dacommented, Sep 12, 2022

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).

0reactions
S11001001commented, Sep 20, 2022

#15022 should address the empty results when disableContractPayloadIndexing=true. It does not help with the Oracle Text error when the index is enabled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Error - Oracle Help Center
In cases where a JavaScript Object Notation (JSON) transaction fails, the API Gateway can use a JSON Error to convey error information to...
Read more >
39 JSON in Oracle Database
Oracle Database provides SQL access to JSON data using Oracle JSON path expressions. JSON is a notation for JavaScript values. When JSON data...
Read more >
Querying JSON with Oracle Database 12c Release 2
In Oracle there is no explicit JSON data type. JSON documents are stored in the database using standard Oracle data types such as...
Read more >
SQL/JSON Condition JSON_EXISTS - Oracle Help Center
SQL/JSON condition json_exists lets you use a SQL/JSON path expression as a row filter, to select rows based on the content of JSON...
Read more >
How to Store, Query, and Create JSON Documents in Oracle ...
Store JSON in a database table; Query a table for rows storing ... As JSON is text, the obvious choice for storing it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found