mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) add GVISOR_LIMIT_MEMORY to cap memory available in sandbox
Summary: This allows limiting the memory available to documents in the sandbox when gvisor is used. If memory limit is exceeded, we offer to open doc in recovery mode. Recovery mode is tweaked to open docs with tables in "ondemand" mode, which will generally take less memory and allow for deleting rows. The limit is on the size of the virtual address space available to the sandbox (`RLIMIT_AS`), which in practice appears to function as one would want, and is the only practical option. There is a documented `RLIMIT_RSS` limit to `specifies the limit (in bytes) of the process's resident set (the number of virtual pages resident in RAM)` but this is no longer enforced by the kernel (neither the host nor gvisor). When the sandbox runs out of memory, there are many ways it can fail. This diff catches all the ones I saw, but there could be more. Test Plan: added tests Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3398
This commit is contained in:
@@ -110,7 +110,7 @@ import {Events as BackboneEvents} from 'backbone';
|
||||
* @property {Number} data - An array of unread invites (see app/common/sharing).
|
||||
*/
|
||||
|
||||
const ValidEvent = StringUnion('docListAction', 'docUserAction', 'docShutdown',
|
||||
const ValidEvent = StringUnion('docListAction', 'docUserAction', 'docShutdown', 'docError',
|
||||
'clientConnect', 'clientLogout',
|
||||
'profileFetch', 'userSettings', 'receiveInvites');
|
||||
type ValidEvent = typeof ValidEvent.type;
|
||||
@@ -213,8 +213,10 @@ export class Comm extends dispose.Disposable implements GristServerAPI, DocListA
|
||||
private _connections: Map<string|null, GristWSConnection> = new Map();
|
||||
private _collectedUserActions: UserAction[] | null;
|
||||
private _singleWorkerMode: boolean = getInitialDocAssignment() === null; // is this classic Grist?
|
||||
private _reportError?: (err: Error) => void; // optional callback for errors
|
||||
|
||||
public create() {
|
||||
public create(reportError?: (err: Error) => void) {
|
||||
this._reportError = reportError;
|
||||
this.autoDisposeCallback(() => {
|
||||
for (const connection of this._connections.values()) { connection.dispose(); }
|
||||
this._connections.clear();
|
||||
@@ -469,6 +471,7 @@ export class Comm extends dispose.Disposable implements GristServerAPI, DocListA
|
||||
err.shouldFork = message.shouldFork;
|
||||
console.log(`Comm response #${reqId} ${r.methodName} ERROR:${code} ${message.error}`
|
||||
+ (message.shouldFork ? ` (should fork)` : ''));
|
||||
this._reportError?.(err);
|
||||
r.reject(err);
|
||||
} else {
|
||||
console.log(`Comm response #${reqId} ${r.methodName} OK`);
|
||||
|
||||
Reference in New Issue
Block a user