Skip to content

Commit

Permalink
Port more 0.10 changes (#456)
Browse files Browse the repository at this point in the history
* Restart summarizer when it completes and do not run new summarizer if already running (#348)

* Container handle errors during reload context [0.10] (#369)

* Handle errors during reloadContext and await pause/resume calls

* Always emit errors and reject promise on error

* Change reloadContext to reject throw error on catch

* Refactor SummaryManager [0.10] (#362)

* Change SummaryManager to state machine

* Remove shouldNotStop telemetry event

* Clean up switch statement to prevent fallthrough

* Small changes for PR feedback

* Use finally for run completion

* Summarize more frequently [0.10] (#371)

* Quorum ops count towards summarizer heuristics; summarizer handle ops while summarizing or pending

* Ignore summarizer leave messages, just in case

* Refactor summarizer code

* Add telemetry and small refactors

* Add comments; small refactor of summary op handling; track seq instead of flag
  • Loading branch information
Arin Taylor committed Oct 31, 2019
1 parent 0974335 commit 529fb19
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 204 deletions.
2 changes: 1 addition & 1 deletion packages/loader/container-definitions/src/chaincode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export interface IContainerContext extends EventEmitter, IMessageScheduler, IPro

error(err: any): void;
requestSnapshot(tagMessage: string): Promise<void>;
reloadContext(): void;
reloadContext(): Promise<void>;
refreshBaseSummary(snapshot: ISnapshotTree): void;
}

Expand Down
20 changes: 12 additions & 8 deletions packages/loader/container-loader/src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,18 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
this.emit("error", error);
}

public reloadContext(): void {
// pause inbound synchronously
this.deltaManager!.inbound.systemPause();
this.deltaManager!.inboundSignal.systemPause();

this.reloadContextCore().then(() => {
this.deltaManager!.inbound.systemResume();
this.deltaManager!.inboundSignal.systemResume();
public reloadContext(): Promise<void> {
return this.reloadContextCore().catch((error) => {
this.raiseCriticalError(error);
throw error;
});
}

private async reloadContextCore(): Promise<void> {
await Promise.all([
this.deltaManager!.inbound.systemPause(),
this.deltaManager!.inboundSignal.systemPause()]);

const previousContextState = await this.context!.stop();

let snapshot: ISnapshotTree | undefined;
Expand All @@ -407,6 +407,10 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
};

await this.loadContext(attributes, storage, snapshot);

await Promise.all([
this.deltaManager!.inbound.systemResume(),
this.deltaManager!.inboundSignal.systemResume()]);
}

private async snapshotCore(tagMessage: string, fullTree: boolean = false) {
Expand Down
4 changes: 2 additions & 2 deletions packages/loader/container-loader/src/containerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ export class ContainerContext extends EventEmitter implements IContainerContext
return;
}

public reloadContext() {
this.container.reloadContext();
public reloadContext(): Promise<void> {
return this.container.reloadContext();
}

private async load() {
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/container-runtime/src/containerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
ISignalMessage,
ISnapshotTree,
ISummaryConfiguration,
ISummaryContent,
ISummaryTree,
ITree,
MessageType,
Expand Down Expand Up @@ -1127,7 +1128,7 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
return ret;
}
const handle = await this.context.storage.uploadSummary(treeWithStats.summaryTree);
const summary = {
const summary: ISummaryContent = {
handle: handle.handle,
head: parents[0],
message,
Expand Down
Loading

0 comments on commit 529fb19

Please sign in to comment.