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 Rate exceeded errors found in npm run migrate #225

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

santiagoars
Copy link
Contributor

@santiagoars santiagoars commented Feb 14, 2025

Fix Rate exceeded errors found in npm run migrate

Description

If a user runs the npm run migrate command one or more times without waiting for a long period of time, the Database will return the following error:

{
  code: 'DatabaseConnectionError',
  title: 'Database Connection Error',
  message: 'The connection pool named: <SCHEMA>|<DB_URL>|re|, encountered a network operation error: ORA-12530: TNS:listener: rate limit reached (CONNECTION_ID=Zo2TS3ifRQe83tN/4KgGkA==)\n' +
    'https://docs.oracle.com/error-help/db/ora-12530/',
  type: 'tag:oracle.com,2020:error/DatabaseConnectionError',
  instance: 'tag:oracle.com,2020:ecid/dc7b7f853eaa3590f57c5ee54c223969'
}

To avoid this, we have changed the iteration mechanism when executing PL/SQL statements to add the SQL Developer Role. Our previous implementation was using the .map() function, which was executing requests in parallel. The new implementation stores the each promise first and will execute each promise sequentially, making use of the reduce() function to achieve this. The result is no more DB errors regardless of how many times a user runs the migrate script.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Ran the migrate scripts 10 different times in the span of ~2 minutes and no rate limit errors where produced. Executing the same test with the main branch produced rate limit errors in all executions after the first run.
  • Made sure that the objects were still being correctly created in the DB and tested the app's functionality. Everything was working correctly.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings/errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 14, 2025
Copy link
Contributor

@oiramS oiramS left a comment

Choose a reason for hiding this comment

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

Overall the goal of this ticket is to reduce the number of calls that the template requires to autoREST enable all of the required objects. I am not entirely sure on the amount of request the migrate script does, but If it's possible to reduce the autoREST calls (8!) to one it would be great.

Comment on lines +107 to +112
await sqlDevObjects.reduce(async (previousPromise, sqlDevObject) => {
await previousPromise;
const statementResponse = await postRequest(endpoint, sqlDevObject, basicAuth);
printResponse(statementResponse);
});
return Promise.resolve();
}, Promise.resolve());
Copy link
Contributor

@oiramS oiramS Feb 14, 2025

Choose a reason for hiding this comment

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

I don't really see how this approach is helping us to reduce the number of calls that the migrate script is making to the database if it's going to will end up calling a postRequest for each statement anyways. I think that a better approach would be to perform a join on the 8 sqlDevObjects statements that will be executed and then perform a single post request. Similar to what we are already doing in the autoRESTDisableObjects function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement. templates-ords-remix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants