Jira (PDB-5364) Enabling log-queries in 7.7.1 causes JSON serialization failures

24 views
Skip to first unread message

Jarret Lavallee (Jira)

unread,
Nov 11, 2021, 12:00:03 PM11/11/21
to puppe...@googlegroups.com
Jarret Lavallee created an issue
 
PuppetDB / Bug PDB-5364
Enabling log-queries in 7.7.1 causes JSON serialization failures
Issue Type: Bug Bug
Affects Versions: PDB 7.7.1
Assignee: Unassigned
Components: PuppetDB
Created: 2021/11/11 8:59 AM
Priority: Normal Normal
Reporter: Jarret Lavallee

In PDB 7.7.1, if log-queries = true some PDB queries will fail with Cannot JSON encode object of class: class org.postgresql.jdbc.PgArray. This was working in 7.5.2. Disabling log-queries alleviates the issue.

 

Reproduction

  1. Install 7.7.1 or PE 2021.4.0
  2. Set log-queries = true in the jetty.ini
  3. Run the following query and observe the error

# curl -G http://localhost:8080/pdb/query/v4/facts --data-urlencode 'query=["extract", ["certname", "name", "value"], ["and", ["or", ["in", "certname", ["array", ["somenode"]]]], ["in", "name", ["array", ["aio_agent_version"]]]]]'
Cannot JSON encode object of class: class org.postgresql.jdbc.PgArray: {"somenode"} 

 

Impact

This query is generated from bolt, so running bolt against a PE instance in 2021.4.0 with log-queries = true will fail.

 

# bolt task run facts --targets $(puppet config print certname) --transport pcp
Started on pe-server-16712b-0.us-west1-c.c.customer-support-scratchpad.internal...
Failed on pe-server-16712b-0.us-west1-c.c.customer-support-scratchpad.internal:
  Query to PuppetDB v4/facts failed with query ["extract" ["certname" "name" "value"] ["and" ("or" ["in" "certname" ["array" ("pe-server-16712b-0.us-west1-c.c.customer-support-scratchpad.internal")]]) ["in" "name" ["array" ["aio_agent_version"]]]]]: Cannot JSON encode object of class: class org.postgresql.jdbc.PgArray: {"pe-server-16712b-0.us-west1-c.c.customer-support-scratchpad.internal"}
Failed on 1 target: pe-server-16712b-0.us-west1-c.c.customer-support-scratchpad.internal
Ran on 1 target in 0.55 sec 

 

Workaround

Set log-queries = false or remove the line from the jetty.ini

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Austin Blatt (Jira)

unread,
Nov 12, 2021, 12:42:02 PM11/12/21
to puppe...@googlegroups.com

Austin Blatt (Jira)

unread,
Dec 1, 2021, 12:47:02 PM12/1/21
to puppe...@googlegroups.com

Rob Browning (Jira)

unread,
Dec 7, 2021, 6:24:01 PM12/7/21
to puppe...@googlegroups.com
Rob Browning updated an issue
Change By: Rob Browning
Fix Version/s: PDB 7.8.0
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Austin Blatt (Jira)

unread,
Dec 7, 2021, 7:25:01 PM12/7/21
to puppe...@googlegroups.com

Austin Blatt (Jira)

unread,
Dec 7, 2021, 7:25:02 PM12/7/21
to puppe...@googlegroups.com

Andreas Papst (Jira)

unread,
Jan 18, 2022, 7:34:02 AM1/18/22
to puppe...@googlegroups.com
Andreas Papst commented on Bug PDB-5364
 
Re: Enabling log-queries in 7.7.1 causes JSON serialization failures

Hello,

same issue here with puppetdb 7.8.0-1buster  :

 

$ curl -X GET http://localhost:8080/pdb/query/v4 --data-urlencode 'query= facts[certname, name]{ name in ["fact1", "fact2"] }'
Cannot JSON encode object of class: class org.postgresql.jdbc.PgArray: {"fact1","fact2"}

 

I've got a hint:

https://stackoverflow.com/questions/29819540/org-postgresql-util-pgobject-cannot-be-cast-to-org-postgresql-util-pgobject

This can only really happen when you have multiple versions of the Postgresql JDBC driver on your classpath. Maybe one in your webapp and another one in the servlet container itself. Make sure to only have one such jar file.

 

Maybe a fix should be easy now.

 

Regards

Andreas

David McTavish (Jira)

unread,
Feb 9, 2022, 2:53:03 PM2/9/22
to puppe...@googlegroups.com

Charlie Sharpsteen (Jira)

unread,
Feb 9, 2022, 6:06:01 PM2/9/22
to puppe...@googlegroups.com

Charlie Sharpsteen (Jira)

unread,
Feb 9, 2022, 6:07:02 PM2/9/22
to puppe...@googlegroups.com
Charlie Sharpsteen commented on Bug PDB-5364
 
Re: Enabling log-queries in 7.7.1 causes JSON serialization failures

This issue also affects PuppetDB 6.19.1 in PE 2019.8.9.

Austin Blatt (Jira)

unread,
Feb 9, 2022, 6:14:03 PM2/9/22
to puppe...@googlegroups.com

Austin Blatt (Jira)

unread,
Feb 9, 2022, 6:17:02 PM2/9/22
to puppe...@googlegroups.com
Austin Blatt updated an issue
 
Change By: Austin Blatt
Fix Version/s: PDB 7.9.0
Fix Version/s: PDB 6.20.0

Charlie Sharpsteen (Jira)

unread,
Feb 9, 2022, 6:36:02 PM2/9/22
to puppe...@googlegroups.com
Charlie Sharpsteen commented on Bug PDB-5364
 
Re: Enabling log-queries in 7.7.1 causes JSON serialization failures

Looks like PDB-5259 fixed this in passing by adding an encoder for PgArray objects along with performance optimizations. Should be present in 6.20.0 and 7.9.0.

Reply all
Reply to author
Forward
0 new messages