-
Notifications
You must be signed in to change notification settings - Fork 246
chore(data-service, connections): make sure that instance info is only fetched once on initial connection COMPASS-9549 COMPASS-7675 #7089
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
Conversation
…y fetched once on initial connection
| // pass it down to telemetry and instance model. This is a relatively | ||
| // expensive dataService operation so we're trying to keep the usage | ||
| // very limited | ||
| const instanceInfo = await dataService.instance(); |
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 is somewhat a breaking change in Compass behavior as described in COMPASS-7675 but I think it's probably okay to do so as we were already discussing doing this. Basically the main change in the behavior here is that some connection related errors that would show up in this weird state where you connected, but we didn't even manage to get to the listing database part of the logic before now will start showing up as part of the connection flow, this doesn't sound too bad to me, but I also asked Betsy to confirm in the ticket
| /** | ||
| * Get the current instance details. | ||
| * | ||
| * @deprecated avoid using `instance` directly and use `InstanceModel` instead |
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.
Literally everywhere except for those initial / inside models fetches we should be using models instead, so I'm adding this marking to make IDEs highlight the method usage
| connections.getDataServiceForConnection(instanceConnectionId); | ||
| const connectionString = dataService.getConnectionString(); | ||
| const firstHost = connectionString.hosts[0] || ''; | ||
| const [hostname, port] = firstHost.split(':'); |
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.
Not new code, but isn't this problematic for IPv6 addresses
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.
Yeah, good catch (and we are accounting for it in other places), I'll adjust while I'm moving stuff around here
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.
Updated in a8f551c
| // We're trying to optimise the initial Compass loading times here: to | ||
| // make sure that the driver connection pool doesn't immediately get | ||
| // overwhelmed with requests, we fetch instance info only once and then |
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.
Yea, in fact it doesn't really matter what we set our pool size to, browsers do not permit more than 6 parallel connections to be creating at the same time.
It obviously matters for our total count in the long run, but at least at boot that's our bottleneck.
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.
We still have multiplexing in the plans, right? Just wondering
|
I had a ticket that was somewhat covering the change you're proposing here, just repurposing it to track this: https://jira.mongodb.org/browse/COMPASS-9549 I assigned the ticket to you, but happy to pick up this if needs further iteration (seems like it is pretty good though!) |
|
Got confirmation from Betsy that this is an okay change in behavior from her perspective, so marking as ready for review |
| connections, | ||
| 'connected', | ||
| function ( | ||
| instanceConnectionId: string, |
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.
We're now tacking on more positional arguments. Wouldn't one object where you can just pick what you want from it start to make more sense? Or do we have too many things using this and that would involve lots of changes? Or is there some other reason I can't immediately spot why we can't change it?
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.
I'll take a closer look at the usage, adding a positional was just the easiest for me, but generally speaking yes, we can probably pack it all into one object (also instanceConnectionId is just connectionInfo.id, so I'll just drop it I think)
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.
I went back and forth on this and decided not to change this, I started moving them to an object of properties, but then disconnect event is different and wanted to keep them consistent, but then connectionId is like the only used argument in disconnect and having it inside an object was weird, so I was trying different combinations, like maybe keeping connectionId as an argument, but moving everything else into an object in a second argument, and this also didn't look right, then I thought I'm overthinking it and it was cleaner to just keep it as is. Hope that's okay
| instance.set({ | ||
| status: 'ready', | ||
| statusError: null, | ||
| ...(instanceInfo as Partial<MongoDBInstanceProps>), |
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.
Maybe I'm reading this wrong, but don't you want status and statusError to override what's already on instanceInfo rather than the other way around?
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.
Actually, I can just pass it all one line higher to the constructor. Generally speaking you're right about this, on practice we won't get those as part of instanceInfo, but absolutely doesn't hurt to be more precise about this
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.
Updated in a8f551c
| err | ||
| ); | ||
| }); | ||
| void dispatch( |
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.
So showEndOfLifeMongoDBWarningModal() now may or may not show the modal because it looks up latestEndOfLifeServerVersion and decides for itself?
Wondering if it should be renamed to something like maybeShowEndOfLifeMongoDBWarningModal() to reflect that. (yes I realise that that's a wildly long and specific name as I type it..)
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.
Yeah, I don't mind renaming it. Also maybe I should've kept it under an if statement here to be honest, I'll take another look and adjust either way
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.
Decided to split into two methods, updated in 7ecdc82
lerouxb
left a 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.
Looks good to me. Just some nitpicky comments, feel free to ignore.
…model; pass instance info to constructor instead of extra .set call
Something that came up as a low hanging fruit in terms of potentially speeding up the initial compass connection. We are running all these
dataService.instancerequests in parallel and so if your connection pool is big enough and can be poulated quickly it's not really a big issue, but in compass-web where initial connection times are slow and pool is pretty limited, removing redundant calls might have a positive effect on connection timesDefinitely better to review with ws changes off, diff is over-reporting here