Added out_pgsql plugin to support output to PostgreSQL#1931
Conversation
|
@sxd My understanding of the contributing guidelines is that the commit message should be something like "out_ pgsql: new plugin to support output to PostgreSQL" See: https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md#commit-changes |
yeah! that's correct that was the first commit in the base source but forgot the rule here, thanks for the remind =) Thanks! |
|
@sxd I've submitted another change request |
thank you! working on it |
edsiper
left a comment
There was a problem hiding this comment.
I've added some license change requests
|
@PettitWesley comments? |
|
(This comment is mostly for my benefit so I can look back at it later) To get this to build on Amazon Linux (context: I maintain aws-for-fluent-bit which is built on amazon linux), I had to create a symlink for the postgre header file: |
|
@sxd I tested with the following config: And Fluent Bit crashed with: Note the |
I'm checking this, give me a few minutes |
|
@PettitWesley ok checking again looks like the name "Table" was taken and read somewhere before, don't know where but it's not the first time, had the same issue with other names before. I'm changing the name of the conf variable now |
|
@PettitWesley look into the solution, it was more related to flb_sds_create() behavior rather than anything else =) |
|
Same as out_kafka, due to external dependencies
…On Thu, Feb 6, 2020, 21:56 Wesley Pettit ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In CMakeLists.txt
<#1931 (comment)>:
> @@ -141,6 +141,7 @@ option(FLB_OUT_PLOT "Enable Plot output plugin" Yes)
option(FLB_OUT_FILE "Enable file output plugin" Yes)
option(FLB_OUT_TD "Enable Treasure Data output plugin" Yes)
option(FLB_OUT_RETRY "Enable Retry test output plugin" No)
+option(FLB_OUT_PGSQL "Enable PostgreSQL output plugin" No)
Curious: Why disable by default? (Not suggesting that's wrong, just want
to understand).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1931?email_source=notifications&email_token=AAC2INVRCKMTOXTXDNJI6QDRBTLVHA5CNFSM4KP3QFC2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCUT2GCQ#pullrequestreview-354919178>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC2INUJ4ZGW6QGSQRNLSA3RBTLVHANCNFSM4KP3QFCQ>
.
|
|
@sxd So I tested it a few times, and it worked at first. Then I think the client ran into a connection issue (or something) which led the code to crash: My config is the same as last time. |
|
I'm not sure what causes the current When Fluent Bit crashes, I believe you can not necessarily count on log messages being printed- if there was a log line right before the crash, it might not be printed. For debugging purposes, you might be able to get around this by adding calls to |
|
let me know if we are ready to grab a beer :) |
PettitWesley
left a comment
There was a problem hiding this comment.
@sxd A bunch of suggestions, and a few required changes involving memory allocations.
I tested it again; Valgrind did not turn up anything this time.
I'll note though that I saw a lot of the same warning:
[2020/03/04 08:24:21] [ warn] [out_pgsql] another command is already in progress
[2020/03/04 08:24:21] [ warn] [out_pgsql] another command is already in progress
[2020/03/04 08:24:21] [ warn] [out_pgsql] another command is already in progress
hoo yeah that's because there must be a command running or pushing that's another issue that we may want to discuss like provide the install of pgbouncer for connection pooling on the postgresql side, that's because we open just one connection and needs to handle all that in only one :( |
|
I would like to get this merged for v1.4 release in "experimental mode" and iterate over it after that. Do you guys think this is ready to go from that perspective ? |
|
@edsiper @sxd I am ready to approve it for "experimental mode" provided that the issues raised in my last review are addressed:
|
|
|
I wasn't able to reproduce this for the last three hours, can you confirm that you can produce it? The case is that if theres any |
|
@sxd I am still seeing the error. This is the part that specifically keeps coming up; the error does not usually appear on the first round of flushes, but happens by the 2nd or third: Notice the single quote before the Postgre version: |
| } | ||
|
|
||
| snprintf(query, str_len, | ||
| "INSERT INTO %s SELECT * FROM json_array_elements('%s');", |
There was a problem hiding this comment.
I wonder if this is the line of code that causes the issue I saw?
There was a problem hiding this comment.
Yeah that's the line we changed to insert data... I'm using PostgreSQL 11 I'll try with that version later in the day
There was a problem hiding this comment.
with that version I mean "10.4" sorry not to be clear
There was a problem hiding this comment.
@PettitWesley @sxd Btw, I tried out 1.4.1, and ran into this same issue. I think the issue happens when there's a single quote in the json. I'm not super familiar with C or fluent-bit, but according to this stack overflow issue I think the solution would be to replace all single quotes with two single quotes to escape them.
There was a problem hiding this comment.
Thank you Tucker! sadly the solution means that we may run into a few more issues so I expect to have an answer tomorrow =) will keep you post!
Thanks again @tuckerconnelly
There was a problem hiding this comment.
Thanks Jonathan, looking forward to the fix--let me know if I can do any testing or help at all.
|
@sxd I have been unable to reproduce this issue if I switch to a new table name (instead of the default "fluentbit" table which I have been using since I first started reviewing this plugin). May be that's the problem- it has old data in it?? |
it's probably since we changed the way to put data inside to something more effective, can you share me a dump with your old data? that will help me a lot since I don't have old data on my table :/ |
@sxd I'm not sure how to do that. I think that as long we can not reproduce this problem with the current iteration of the code it is fine. |
PettitWesley
left a comment
There was a problem hiding this comment.
I think the code looks good. Let's not merge it till @sxd finishes testing though.
Signed-off-by: Jonathan Gonzalez V <jonathan.gonzalez@2ndquadrant.com>
I've been testing since yesterday and haven't hit a bug yet so I think we're fine for an experimental state of this |
|
thanks @sxd and @PettitWesley for the hard work on this! |

this pull request refers to issue #1739
Signed-off-by: Jonathan Gonzalez V jonathan.gonzalez@2ndquadrant.com