Skip to content

[SDK-222] [no connection serial ] + implement missing internal presence map + presencequeue#621

Merged
sacOO7 merged 125 commits intofeature/integration-2.0from
fix/presencemap
Dec 13, 2023
Merged

[SDK-222] [no connection serial ] + implement missing internal presence map + presencequeue#621
sacOO7 merged 125 commits intofeature/integration-2.0from
fix/presencemap

Conversation

@sacOO7
Copy link
Copy Markdown
Collaborator

@sacOO7 sacOO7 commented Aug 14, 2023

@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 14, 2023 17:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 14, 2023 17:28 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 14, 2023 18:21 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 14, 2023 18:22 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 14, 2023 19:41 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 14, 2023 19:42 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 15, 2023 14:16 Inactive
@sacOO7 sacOO7 changed the base branch from main to feature/integration-2.0 August 15, 2023 14:17
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 15, 2023 14:17 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 15, 2023 17:52 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 15, 2023 17:53 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 15, 2023 18:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 15, 2023 18:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 15, 2023 19:47 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 15, 2023 19:48 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 15, 2023 19:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 15, 2023 19:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 15, 2023 19:56 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/godoc August 15, 2023 19:56 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/621/features August 16, 2023 09:11 Inactive
Copy link
Copy Markdown
Member

@lmars lmars left a comment

Choose a reason for hiding this comment

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

I've given high level review based on Go code alone, I defer to others with more context about the functional changes.

Comment thread ably/export_test.go Outdated
Comment thread ably/export_test.go Outdated
Comment thread ably/proto_protocol_message_test.go
Comment thread ably/realtime_channel.go Outdated
Comment thread ably/realtime_channel.go Outdated
Comment thread ably/realtime_presence.go
Comment thread ably/realtime_presence.go Outdated
Comment thread ably/realtime_channel.go Outdated
Comment thread ably/realtime_presence.go
}
}

func (pres *RealtimePresence) onAttach(msg *protocolMessage, isAttachWithoutMessageLoss bool) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The naming of isAttachWithoutMessageLoss seems misleading. That'll be set to true in any situation where you need to re-enter your members, which includes both situations where you do and don't have message loss

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Let's say, if you attached channel when previous state was detached or attaching, do we get resume as false in such a case?

Copy link
Copy Markdown
Collaborator Author

@sacOO7 sacOO7 Dec 2, 2023

Choose a reason for hiding this comment

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

So, we should just call it shouldEnterInternalMembers wdyt?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't find any meaningful name that can denote the cause for this boolean flag : (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's say, if you attached channel when previous state was detached or attaching, do we get resume as false in such a case?

That, well, depends whether you resumed, because that's what the flag tells you. So you can go from attaching->attached with resumed=true or from attaching->attached with resumed=true with resumed=false.

But in protocol v2, whether you resumed is irrelevant. RTP17f: you should perform automatic re-entry whenever a channel moves into the ATTACHED state (from a different state). It doesn't matter whether you resumed, you do it either way.

Comment thread ably/realtime_channel.go
Comment thread ably/realtime_conn.go
if onAck != nil {
onAck(connStateError(state, nil))
if c.state == ConnectionStateClosed {
onAck(errClosed)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why does closed need to be special-cased? can't it be handled by connStateError(state) like all the others?

Copy link
Copy Markdown
Collaborator Author

@sacOO7 sacOO7 Dec 3, 2023

Choose a reason for hiding this comment

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

Actually

ably-go/ably/state.go

Lines 55 to 60 in e66ad6a

var connStateErrors = map[ConnectionState]ErrorInfo{
ConnectionStateInitialized: *errNeverConnected,
ConnectionStateDisconnected: *errDisconnected,
ConnectionStateFailed: *errFailed,
ConnectionStateSuspended: *errSuspended,
}
map doesn't contain errClosed.
At the same time, we can't update the map to include errClosed since it can be a graceful close from the client side.
If we update the map with errClosed, other tests start failing where we don't expect error when client goes into closed state
E.g. call to client.close(), and conn state changes to closed with error.
This error is specific to our use-case, so I didn't include it in the map

Copy link
Copy Markdown
Member

@SimonWoolf SimonWoolf Dec 4, 2023

Choose a reason for hiding this comment

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

At the same time, we can't update the map to include errClosed since it can be a graceful close from the client side.

I don't follow. If the connection is closed, then most operations you try to do to it (other than reconnect) should fail with a 'connection closed' error, similarly to if it's failed. if connclosed is missing from that then either every place you call is going to need to check if the conn is closed and handle that explicitly, or you have a bug, no?

E.g. call to client.close(), and conn state changes to closed with error.

No it doesn't because connection state changes don't have errors. They have reasons. The reason might be 'the connection was closed', that's not an error, it's telling you the reason that the connection is in that state

Copy link
Copy Markdown
Collaborator Author

@sacOO7 sacOO7 Dec 4, 2023

Choose a reason for hiding this comment

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

I think there is errorReason =>

// errorReason is an [ably.ErrorInfo] object describing the last error received if
// a connection failure occurs (RTN14a).
errorReason *ErrorInfo

and same is copied into reason

ably-go/ably/realtime_conn.go

Lines 1001 to 1006 in e66ad6a

change := ConnectionStateChange{
Current: c.state,
Previous: previous,
Reason: c.errorReason,
RetryIn: retryIn,
}

There are tests which don't treat connection closed to be connection failure as such. I mean ideally, they shouldn't.
Because client.close() initiates it and gracefully closes the connection accordingly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do we have a spec item that specifies to set a reason when client explicitly sends a close message and connection is closed by server

Comment thread ably/realtime_conn.go
Comment thread ably/realtime_presence.go Outdated
Copy link
Copy Markdown
Member

@lmars lmars left a comment

Choose a reason for hiding this comment

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

This looks ok from my perspective, but I defer to @SimonWoolf to review the changes he requested

@sacOO7
Copy link
Copy Markdown
Collaborator Author

sacOO7 commented Dec 13, 2023

@lmars merging this PR into integration-2.0, since one more review required for recovery spec related commits. I will re-raise @SimonWoolf comments there

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.

RTP2, RTP17, RTP19: PresenceMap

3 participants