Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedded documents update for array elements lead to postgres restart #155

Open
zhang699 opened this issue Jan 11, 2022 · 3 comments
Open

Comments

@zhang699
Copy link

zhang699 commented Jan 11, 2022

I have use pgAdmin GUI to test embedded update by mongo_fdw

Tested Documents

collection: warehouse
{
  _id: ObjectId("61d7ad616372f5550c92ac4b"),
  elements: ["a", "b"]
}

SQL Schema

id: name
elements: text[]
  • Try the query
UPDATE warehouse SET elements[1] = 'test' WHERE _id = '61d7ad616372f5550c92ac4b'
  • Query Log
Connection to the server has been lost
  • Postgres Console log
postgres_1  | /app/mongo_fdw/mongo-c-driver/src/libbson/src/bson/bson.c:326 _bson_append_va(): precondition failed: !(bson->flags & BSON_FLAG_IN_CHILD)
postgres_1  | 2022-01-11 08:01:52.535 UTC [1] LOG:  server process (PID 1346) was terminated by signal 6: Aborted
postgres_1  | 2022-01-11 08:01:52.535 UTC [1] DETAIL:  Failed process was running: UPDATE warehouse SET elements[1] = 'test' WHERE _id = '61d7ad616372f5550c92ac4b'
postgres_1  | 2022-01-11 08:01:52.535 UTC [1] LOG:  terminating any other active server processes
mongo_1     | {"t":{"$date":"2022-01-11T08:01:52.534+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn15","msg":"Connection ended","attr":{"remote":"192.168.208.4:43870","connectionId":15,"connectionCount":10}}
postgres_1  | 2022-01-11 08:01:52.587 UTC [1] LOG:  all server processes terminated; reinitializing
postgres_1  | 2022-01-11 08:01:52.754 UTC [1348] LOG:  database system was interrupted; last known up at 2022-01-11 07:31:27 UTC
postgres_1  | 2022-01-11 08:01:52.755 UTC [1350] FATAL:  the database system is in recovery mode
postgres_1  | 2022-01-11 08:01:52.756 UTC [1349] FATAL:  the database system is in recovery mode
postgres_1  | 2022-01-11 08:01:52.915 UTC [1348] LOG:  database system was not properly shut down; automatic recovery in progress
postgres_1  | 2022-01-11 08:01:52.918 UTC [1348] LOG:  redo starts at 0/1726960
postgres_1  | 2022-01-11 08:01:52.918 UTC [1348] LOG:  invalid record length at 0/1726A48: wanted 24, got 0
postgres_1  | 2022-01-11 08:01:52.918 UTC [1348] LOG:  redo done at 0/1726A10 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
@vaibhavdalvi93
Copy link

Thanks, @zhang699 for reporting an issue.

I can reproduce the same issue at my end. This is a bug.

The root cause of the issue is that while preparing the query document,
provided the wrong first argument to the function BsonAppendUTF8()
which is called by function AppendMongoValue().

We will work on this issue in near future.

@zhang699
Copy link
Author

Thanks, @zhang699 for reporting an issue.

I can reproduce the same issue at my end. This is a bug.

The root cause of the issue is that while preparing the query document, provided the wrong first argument to the function BsonAppendUTF8() which is called by function AppendMongoValue().

We will work on this issue in near future.

Great !!

jeevanchalke added a commit that referenced this issue Mar 27, 2022
For the array element, in the meta driver, we should be appending the
value to the child document.  However, mistakenly we were adding the
value to the main query document leading to the server crash.  Fix the
same by correctly passing the child document to bsonAppendUTF8().

Reported on GitHub through issue #155 by zhang699.

FDW-466, Vaibhav Dalvi, reviewed by Suraj Kharage,
tested by Ajay Pal.
@vaibhavdalvi93
Copy link

Hi @zhang699 ,

The reported issue has been resolved.
It would be good if you please confirm from your side on latest head/release and close the ticket if it's been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants