Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(satp-hermes): shutdown of SATP gateway should assure there are no pending transfers before shutting down #3802

Open
wants to merge 2 commits into
base: satp-dev
Choose a base branch
from

Conversation

joaoecsde
Copy link

Introduces a new function, verifySessionState, which upon shutdown verifies if all sessions are concluded. Also a flag was created to prevent new transactions to occur when shutdown was already called.

Additionally, a new type of error is introduced gateway-error .

Resolves #3756.
Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

Copy link
Contributor

@LordKubaya LordKubaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but the method of verifying sessions should done in a different approach.

@@ -308,6 +309,17 @@ export class SATPManager {
return this.satpHandlers.get(type);
}

public getSATPSessionState(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document this method

Comment on lines 659 to 678
private async verifySessionsState(): Promise<void> {
const fnTag = `${this.className}#verifySessionsState()`;
this.logger.trace(`Entering ${fnTag}`);
if (!this.BLODispatcher) {
throw new Error(`Cannot ${fnTag} because BLODispatcher is erroneous`);
}
this.BLODispatcher.setInitiateShutdown();
const manager = await this.BLODispatcher.getManager();
let status = false;
while (!status) {
this.logger.debug(`Inside: ${status}`);
status = await manager.getSATPSessionState();
if (!status) {
this.logger.info("Sessions are still pending");
await new Promise(resolve => setTimeout(resolve, 20000));
}
}
this.logger.info("All sessions are concluded");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -224,6 +224,12 @@ export class SATPSession {
return this.serverSessionData?.id || this.clientSessionData?.id || "";
}

public getSessionState(): State {
console.log("serverSessionId: ", this.serverSessionData?.state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the component logger instead of console.log

this.BLODispatcher.setInitiateShutdown();
const manager = await this.BLODispatcher.getManager();
let status = false;
while (!status) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a potential infinite loop. this function might block, and we need to decide if this is desirable behaviour. On one hand, the gateway cannot handle anything else; on the other, it should not serve new requests. So there should be a middle-term that allows the gateway to keep serving other requests (namely admin) while not initiating new transfers nor blocking.

Besides, we might want to include a timeout, since something can be broken in the manager (in particular if there is a hanging SATP transfer, communicating with a counterparty gateway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants