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

Use the correct top_ref when converting from streaming form #1223

Merged
merged 4 commits into from
Oct 20, 2015

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Oct 16, 2015

When skip_validate is true, SlabAlloc::attach_file() always returned 0 for the top_ref. This was fine when it's not the session initiator as the return value was ignored in favor of the ref from the lock file, but SharedGroup::compact() actually uses the return value.

When skip_validate is true, SlabAlloc::attach_file() always returned 0 for the
top_ref. This was fine when it's not the session initiator as the return value
was ignored in favor of the ref from the lock file, but SharedGroup::compact()
actually uses the return value.
@finnschiermer
Copy link
Contributor

Bummer! We introduced this error in PR #1201 a week ago when we fixed a related problem. Good catch.

👍

No doubt that attach_file is too overloaded/serves too many purposes. We've had far too many bugs here (either in attach_file or in functions using it such as SharedGroup::open and compact.)

@finnschiermer
Copy link
Contributor

@kspangsege will you review this one as well? As we've had multiple bugs in this part of the code, we better play it safe.

@finnschiermer
Copy link
Contributor

Correction: this bug was not introduced by PR #1201, but earlier. It is more like a parallel to #1201.
FYI: The bug is not present in Realm core release 0.92.2 (22nd of sept)

@tgoyne
Copy link
Member Author

tgoyne commented Oct 19, 2015

No doubt that attach_file is too overloaded/serves too many purposes.

Too many different modes and potential combinations of modes, too. This change bandaids one broken combination, but I'm pretty sure there's more that just aren't used at the moment.

@kspangsege
Copy link
Contributor

@tg, @finnschiermer, for the sake of clarity I made some further modifications such that SlabAlloc::attach_file() now always returns the top ref. Previously, it would only return the top ref if !skip_validate || session_initiator && on_streaming_form.

@realm-ci
Copy link
Contributor

Header* header = writable_map.get_addr();
header->m_flags |= cfg.server_sync_mode ? flags_ServerSyncMode : 0x0;
Header& header = *writable_map.get_addr();
header.m_flags |= cfg.server_sync_mode ? flags_ServerSyncMode : 0x0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about explicitly setting top_ref in this branch of the if as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you misread the code here. Note that top_ref is already set in both cases, because it is set after the end of the else-block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention is certainly that top_ref must be set in every case, so let me know if you see any case where it fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I can see it is not set when did_create is true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. The closing-opening brace after the first condition confused me. I had to open it in the editor to understand the code :-)

finnschiermer added a commit that referenced this pull request Oct 20, 2015
Use the correct top_ref when converting from streaming form
@finnschiermer finnschiermer merged commit d6e6d08 into master Oct 20, 2015
@kspangsege kspangsege deleted the tg-compact-reattach branch March 19, 2016 18:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants