Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fixes for instanceserver connection bugs (#10766)
Browse files Browse the repository at this point in the history
A rare situation was cropping up where an instance record was
getting removed from the database after an instance provision.
This would cause initializeInstance to return false, and loadEngine
to not run, but instanceStarted would remain true. That instance
wouldn't start, but the server would still remain in the pool of
Ready servers. Later clients assigned to that pod would then just
endlessly wait for InstanceServerState.ready to be true, which
would never happen. setting instanceStarted back to false if
initializeInstance returns false should fix this.

Increased the timeout on assigned but not-connected instances to
60 seconds from 30. This may be what was causing those instance
records to be removed, if a client on a slow network was getting
the provision but then taking more than 30 seconds to make the
websocket connection.
  • Loading branch information
barankyle authored Jul 30, 2024
1 parent 88cc389 commit 3b1af2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/instanceserver/src/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const updateInstance = async ({
instanceStarted = true
const initialized = await initializeInstance({ app, status, headers, userId })
if (initialized) await loadEngine({ app, sceneId, headers })
else instanceStarted = false
return true
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function getFreeInstanceserver({
query: {
assigned: true,
assignedAt: {
$lt: toDateTimeSql(new Date(new Date().getTime() - 30000))
$lt: toDateTimeSql(new Date(new Date().getTime() - 60000))
}
},
headers
Expand Down Expand Up @@ -510,7 +510,7 @@ export class InstanceProvisionService implements ServiceInterface<InstanceProvis
query: {
assigned: true,
assignedAt: {
$lt: toDateTimeSql(new Date(new Date().getTime() - 30000))
$lt: toDateTimeSql(new Date(new Date().getTime() - 60000))
}
}
})
Expand Down Expand Up @@ -615,7 +615,7 @@ export class InstanceProvisionService implements ServiceInterface<InstanceProvis
query: {
assigned: true,
assignedAt: {
$lt: toDateTimeSql(new Date(new Date().getTime() - 30000))
$lt: toDateTimeSql(new Date(new Date().getTime() - 60000))
}
}
})
Expand Down

0 comments on commit 3b1af2b

Please sign in to comment.