mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 02:01:47 +03:00
Soft retries when awaiting runtime responses (#10272)
A quick and dirty workaround for slow processing in a similar spirit to PR #9858. Long compilation of stdlib holds a write compilation lock, while opening the file needs to set module sources and requires read compilation lock and file lock. The expectation was that setting module sources is instantaneous except not, because of locks. This PR adds soft retries. Partially closes #10231. There are still problems related to https://github.com/enso-org/enso/issues/9993 once this PR is merged. # Important Notes We need to figure out a more fine-grained lock system or, ideally, make it lock free to avoid such hacks.
This commit is contained in:
parent
904ffe1dd6
commit
dc6e3a7031
@ -152,12 +152,36 @@ class CollaborativeBuffer(
|
|||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
rpcSession: JsonSession,
|
rpcSession: JsonSession,
|
||||||
replyTo: ActorRef,
|
replyTo: ActorRef,
|
||||||
timeout: Cancellable
|
timeout: Cancellable,
|
||||||
|
retries: Int
|
||||||
): Receive = {
|
): Receive = {
|
||||||
case ServerConfirmationTimeout =>
|
case ServerConfirmationTimeout =>
|
||||||
logger.warn("Timeout reached when awaiting response from the server")
|
if (retries > 0) {
|
||||||
replyTo ! OpenFileResponse(Left(OperationTimeout))
|
logger.warn(
|
||||||
stop(Map.empty)
|
"Timeout reached when awaiting response from the server. Retries left {}",
|
||||||
|
retries
|
||||||
|
)
|
||||||
|
val timeoutCancellable = context.system.scheduler
|
||||||
|
.scheduleOnce(
|
||||||
|
timingsConfig.runtimeRequestTimeout,
|
||||||
|
self,
|
||||||
|
ServerConfirmationTimeout
|
||||||
|
)
|
||||||
|
context.become(
|
||||||
|
waitingOnServerConfirmation(
|
||||||
|
requestId,
|
||||||
|
buffer,
|
||||||
|
rpcSession,
|
||||||
|
replyTo,
|
||||||
|
timeoutCancellable,
|
||||||
|
retries - 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
logger.warn("Timeout reached when awaiting response from the server")
|
||||||
|
replyTo ! OpenFileResponse(Left(OperationTimeout))
|
||||||
|
stop(Map.empty)
|
||||||
|
}
|
||||||
case Api.Response(Some(id), Api.OpenFileResponse) if id == requestId =>
|
case Api.Response(Some(id), Api.OpenFileResponse) if id == requestId =>
|
||||||
timeout.cancel()
|
timeout.cancel()
|
||||||
val cap = CapabilityRegistration(CanEdit(bufferPath))
|
val cap = CapabilityRegistration(CanEdit(bufferPath))
|
||||||
@ -865,7 +889,8 @@ class CollaborativeBuffer(
|
|||||||
buffer,
|
buffer,
|
||||||
rpcSession,
|
rpcSession,
|
||||||
replyTo,
|
replyTo,
|
||||||
timeoutCancellable
|
timeoutCancellable,
|
||||||
|
5
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user