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

Fix sync connection serial in the event of a failed upgrade #445

Closed
wants to merge 2 commits into from

Conversation

SimonWoolf
Copy link
Member

@SimonWoolf SimonWoolf commented Jan 2, 2018

And rename various connectionSerial variables for clarity

(context from slack: "when it was first written, that code was correct, because at the time, we activated the new transport before syncing, so the first newConnectionSerial was passed to activeTransport and served its purpose. Later on in an unrelated change (https://github.com/ably/realtime/issues/522), to address a race condition, we switched the order of those and started syncing first, but I clearly failed to notice that the logic for when the upgrade failed needed to be updated too")

@@ -387,14 +387,14 @@ var ConnectionManager = (function() {
* be a sync with the new connectionSerial (which will be -1). (And it
* needs to be set in the library, which is done by activateTransport). */
var connectionReset = connectionId !== self.connectionId,
newConnectionSerial = connectionReset ? connectionSerial : self.connectionSerial;
syncConnectionSerial = connectionReset ? preUpgradeConnectionSerial : self.connectionSerial;
Copy link
Member

Choose a reason for hiding this comment

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

scheduleTransportActivation() is passed the connectionSerial from the CONNECTED message when the upgrade transport connects. So how is this the preUpgradeConnectionSerial ?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the sense that the sync as the atomic moment of the actual 'upgrade', so preUpgradeConnectionSerial is the serial of the upgrade transport before that (likely -1). Can change to preSyncConnectionSerial if you think that's clearer

@SimonWoolf
Copy link
Member Author

Merged as 7a63754

@SimonWoolf SimonWoolf closed this Jan 30, 2018
@SimonWoolf SimonWoolf deleted the upgrade-connserial-tweak branch January 30, 2018 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants