Skip to content

Conversation

@IvanBorislavovDimitrov
Copy link
Contributor

@IvanBorislavovDimitrov IvanBorislavovDimitrov commented Sep 29, 2025

LMCROSSITXSADEPLOY-3285

}

@Bean(name = "deployFromUrlExecutor")
public ExecutorService deployFromUrlExecutor() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this is needed when we have asyncFileUploadExecutor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The asyncFileUploadExecutor is used for the actual upload. It has a queue of 20 which means it can store 20 jobs in the queue before starting a new thread.
Such executor will not scale well under load it might not update the update_at column in the database and the job might be consider as stale.
The goal of deployFromUrlExecutor is to update regularly updated_at value in the table and trigger the other executor to schedule the upload.


<include file="/org/cloudfoundry/multiapps/controller/persistence/db/changelog/db-changelog-1.192.0-persistence.xml"/>

<include file="/org/cloudfoundry/multiapps/controller/persistence/db/changelog/db-changelog-1.199.0-persistence.xml"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not forget to align the file with version which will be released

Copy link
Contributor

Choose a reason for hiding this comment

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

2.34.0

// As the threads are only updating a row and waiting it is ok to have more threads
30,
TimeUnit.SECONDS,
new SynchronousQueue<>()); // A synchronous queue is used so deploy from url jobs immediately start
Copy link
Contributor

Choose a reason for hiding this comment

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

What will happen if all threads are busy and there is already one task in the queue waiting for execution? What will happen with all other threads which tries to submit a new task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This queue does not store any jobs, if there is a free thread (up to 50) it will immediately start the job, if there are no available threads (50 are used) it will reject the job. According to statistics there are maximum of around ~320 started operations on eu10-004 per hour (most use normal file upload), so 450 threads seems more than enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

If backend reject file upload task, does the cli will retry on another instance or it will retry on the same one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will check in the plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, usually hit the same instance because of sticky sessions, except the last retry...
described in the backlog for the session handling

@IvanBorislavovDimitrov IvanBorislavovDimitrov force-pushed the deploy-from-url-split branch 4 times, most recently from d9b5cda to 403c257 Compare October 7, 2025 11:45
} finally {
lock.unlock();
}
MiscUtil.sleep(WAIT_TIME_BETWEEN_ASYNC_JOB_UPDATES_IN_MILLIS);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try to use another approach by avoiding putting thread into sleep by using ScheduledExecutorService for monitoring and db update tasks? ScheduledExecutorService has methods to setup execution intervals and method execution delays. This is only idea, if performance is worse, then we can keep it as it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is possible to introduce such an executor but I see a couple of issues with this approach.
We will have 3 executors. Currently these 2 asyncFileUploadExecutor and deployFromUrlExecutor have the same amount of maximum load they can handle:
asyncFileUploadExecutor - 6 threads max + 20 waiting jobs (6th tread is started after the 20th waiting job)
deployFromUrlExecutor - max of 26 threads so it handles the same amount of jobs, without leading to unused threads or failing jobs because the other executor is full.

If we introduce a new executor only to remove the thread sleep it also will have to be synchronized with the above mentioned. Another possible problem is, there will be always one more thread allocated to start the monitoring until the thread is freed from deployFromUrlExecutor. The bigger problem is the synchronization, the deployFromUrlExecutor should start checking the queue of the new scheduled executor so it can decide whether to handle or reject the job. In my opinion seems like unnecessary complication of the code

s-yonkov-yonkov
s-yonkov-yonkov previously approved these changes Oct 9, 2025
theghost5800
theghost5800 previously approved these changes Oct 13, 2025
@theghost5800
Copy link
Contributor

Evaluate security hotpost before merge

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@IvanBorislavovDimitrov IvanBorislavovDimitrov merged commit f50a745 into master Oct 15, 2025
7 of 8 checks passed
@IvanBorislavovDimitrov IvanBorislavovDimitrov deleted the deploy-from-url-split branch October 15, 2025 10:07
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