-
Notifications
You must be signed in to change notification settings - Fork 168
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
Re-create all objects before updating their properties during client_reset::transfer_group() #6291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM-good find!
transfer_group
is an insane function...
@@ -329,8 +329,30 @@ void transfer_group(const Transaction& group_src, Transaction& group_dst, util:: | |||
} | |||
} | |||
|
|||
converters::EmbeddedObjectConverter embedded_tracker; | |||
// We must re-create any missing objects that are abscent in dst before trying to copy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*absent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing objects or objects that are absent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops.
// get or create the object | ||
auto dst = table_dst->create_object_with_primary_key(src_pk, &updated); | ||
auto dst = table_dst->get_object_with_primary_key(src_pk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create the object if it doesn't exist?
Or it should have already been created by your changes above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. I updated the comment above.
@@ -357,11 +379,11 @@ void transfer_group(const Transaction& group_src, Transaction& group_dst, util:: | |||
|
|||
for (const Obj& src : *table_src) { | |||
auto src_pk = src.get_primary_key(); | |||
bool updated = false; | |||
// get or create the object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should update this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Side note: maybe it should be turned into a CHECK so we see the actual error. |
What, How & Why?
This fixes a crash in automatic client resets where there are dangling links in the destination realm (i.e. the realm being client reset). The
transfer_group()
function takes a fresh copy of a realm and transfers a source realm's contents to a target by comparing each property in each object in each table, and creating/setting properties as needed if they don't exist or do not match. If the target table has a list of links where some of them are dangling, and the dangling link targets exist in the source realm, it will create the target objects, thereby resurrecting the dangling link, and end up with duplicate entries in the list. This violates an invariant in the IntraRealmObjectConverter class.☑️ ToDos