From 69704c6a8050bf67d96b6ad8731140463345c220 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 6 Jan 2021 23:12:01 +0100 Subject: [PATCH 1/3] graph: make the join thread back off Pushes the pathological case back a bit, but doesn't make it stop trying. --- pkg/arvo/ted/graph/join.hoon | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/ted/graph/join.hoon b/pkg/arvo/ted/graph/join.hoon index 5837409ae..dbeb6f169 100644 --- a/pkg/arvo/ted/graph/join.hoon +++ b/pkg/arvo/ted/graph/join.hoon @@ -29,13 +29,15 @@ ^- form:m =/ pax (en-path:resource rid) + =/ hold=@dr ~s0..8000 |- ^- form:m =* loop $ ;< u-group=(unit group) bind:m (scry:strandio ,(unit group) (weld /gx/group-store/groups (snoc pax %noun))) ?^ u-group (pure:m ~) - ;< ~ bind:m (sleep:strandio `@dr`(div ~s1 2)) + ;< ~ bind:m (sleep:strandio hold) + =. hold (min (mul hold 2) ~m5) loop :: ++ wait-for-md @@ -44,13 +46,15 @@ ^- form:m =/ pax (en-path:resource rid) + =/ hold=@dr ~s0..8000 |- ^- form:m =* loop $ ;< groups=(set path) bind:m (scry:strandio ,(set path) /gy/metadata-store/group-indices) ?: (~(has in groups) pax) (pure:m ~) - ;< ~ bind:m (sleep:strandio `@dr`(div ~s1 2)) + ;< ~ bind:m (sleep:strandio hold) + =. hold (min (mul hold 2) ~m5) loop -- :: From 3bf03ffc9be4cf4363276a612187fe8cb6329519 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 21 Jan 2021 10:43:25 +1000 Subject: [PATCH 2/3] graph-join: crash on backoff and fix scry mold --- pkg/arvo/ted/graph/join.hoon | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/ted/graph/join.hoon b/pkg/arvo/ted/graph/join.hoon index dbeb6f169..25a18e3b7 100644 --- a/pkg/arvo/ted/graph/join.hoon +++ b/pkg/arvo/ted/graph/join.hoon @@ -31,13 +31,14 @@ (en-path:resource rid) =/ hold=@dr ~s0..8000 |- ^- form:m + ?> (lte hold ~m5) =* loop $ ;< u-group=(unit group) bind:m (scry:strandio ,(unit group) (weld /gx/group-store/groups (snoc pax %noun))) ?^ u-group (pure:m ~) ;< ~ bind:m (sleep:strandio hold) - =. hold (min (mul hold 2) ~m5) + =. hold (mul hold 2) loop :: ++ wait-for-md @@ -48,13 +49,14 @@ (en-path:resource rid) =/ hold=@dr ~s0..8000 |- ^- form:m + ?> (lte hold ~m5) =* loop $ - ;< groups=(set path) bind:m - (scry:strandio ,(set path) /gy/metadata-store/group-indices) - ?: (~(has in groups) pax) + ;< groups=(jug path md-resource) bind:m + (scry:strandio ,(jug path md-resource) /gy/metadata-store/group-indices) + ?: (~(has by groups) pax) (pure:m ~) ;< ~ bind:m (sleep:strandio hold) - =. hold (min (mul hold 2) ~m5) + =. hold (mul hold 2) loop -- :: From 9424e56827175d3f7a8a1c3481069bc261921896 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 21 Jan 2021 10:46:04 +1000 Subject: [PATCH 3/3] graph-api: prevent more than one join request --- pkg/interface/src/logic/api/graph.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/logic/api/graph.ts b/pkg/interface/src/logic/api/graph.ts index 40b9c1aad..0606a2c1e 100644 --- a/pkg/interface/src/logic/api/graph.ts +++ b/pkg/interface/src/logic/api/graph.ts @@ -3,8 +3,8 @@ import { StoreState } from '../store/type'; import { Patp, Path, PatpNoSig } from '~/types/noun'; import _ from 'lodash'; import {makeResource, resourceFromPath} from '../lib/group'; -import {GroupPolicy, Enc, Post, NodeMap, Content} from '~/types'; -import { numToUd, unixToDa, decToUd, deSig } from '~/logic/lib/util'; +import {GroupPolicy, Enc, Post, NodeMap, Content, Resource} from '~/types'; +import { numToUd, unixToDa, decToUd, deSig, resourceAsPath } from '~/logic/lib/util'; export const createBlankNodeWithChildPost = ( parentIndex: string = '', @@ -81,6 +81,8 @@ function moduleToMark(mod: string): string | undefined { export default class GraphApi extends BaseApi { + joiningGraphs = new Set(); + private storeAction(action: any): Promise { return this.action('graph-store', 'graph-update', action) } @@ -138,11 +140,19 @@ export default class GraphApi extends BaseApi { joinGraph(ship: Patp, name: string) { const resource = makeResource(ship, name); + const rid = resourceAsPath(resource); + if(this.joiningGraphs.has(rid)) { + return Promise.resolve(); + } + this.joiningGraphs.add(rid); return this.viewAction('graph-join', { join: { resource, ship, } + }).then(res => { + this.joiningGraphs.delete(rid); + return res; }); }