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

Tests to verify that tasks submitted to executor during deployment are executed #24539

Merged

Conversation

OndroMih
Copy link
Contributor

@OndroMih OndroMih commented Aug 11, 2023

Adds tests for #24544.

This PR was previously raised to fix #21087 but then this was fixed by #24544. What remains in this PR is tests to verify the expected behavior.

@OndroMih OndroMih changed the title Ondromih executors during deployment Fix: tasks submitted to executor during deployment are executed Aug 11, 2023
Triggers the tasks immediately, even before the deployment completes.

To do:
* consider whether it's better to execute the tasks after deployment completed

Signed-off-by:Ondro Mihalyi <[email protected]>
@OndroMih
Copy link
Contributor Author

The failed test ProgressStatusComplexITest doesn't seem to be related to my changes. Can you please check, @dmatej or restart the build?

@dmatej
Copy link
Contributor

dmatej commented Aug 13, 2023

The failed test ProgressStatusComplexITest doesn't seem to be related to my changes. Can you please check, @dmatej or restart the build?

3 failures are weird, does it pass locally?
mvn clean install -T4C -Pfastest && mvn clean install -pl :admin-tests,:application-tests

@@ -250,14 +250,14 @@ private ComponentInvocation getSavedInvocation() {
*/
private boolean isApplicationEnabled(String appId) {
if (appId == null) {
// we don't know the application name yet, it is starting.
return true;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is wrong - the DOL does still some magic. I think I did something similar when I reintroduced concurrency before JEE10 and I broke some other things by this change. I see also my FIXME in the history:

             // we don't know the application name yet, it is starting.
            // FIXME: it would be good to know the application name even in this phase.

You moved the comment down, now it even doesn't make sense, because you return true instead original false.
And javadoc doesn't make sense too - no exception would be thrown, it would return false. Now it returns true.

Copy link
Contributor

@dmatej dmatej Aug 13, 2023

Choose a reason for hiding this comment

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

If it all would be written correctly, for null appId it should throw NPE. We have to get there some day :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning true at the end makes sende - it we have appName but the Application object isn’t created yet, then the app is being deployed and thus it’s enabled. This actually fixes #21087 and it’s a similar fix to how Payara fixed the same issue a while ago.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don’t understand why DOL would call this method with no app name. Then which app is enabled if we return true?

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 change is wrong - the DOL does still some magic. I think I did something similar when I reintroduced concurrency before JEE10 and I broke some other things by this change.

Now I see that a test in application-tests failed exactly because appName is null in ContextSetupProviderimpl (in concurrent-impl). Because invocation.getAppName() is null. I'll try to find out why that happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the reason for invocation.getAppName() == null:
https://github.com/eclipse-ee4j/glassfish/blob/master/appserver/concurrent/concurrent-impl/src/main/java/org/glassfish/concurrent/runtime/ContextSetupProviderImpl.java#L243

By default, no information from the current invocation is saved for a new thread if JNDI isn't propagated. getSavedInvocation() method either returns an empty invocation (if JNDI should be cleared), or null (by defualt). Both are later interpreted as appName == null.

I believe that in both cases, a new invocation should be created and some non-JNDI data should be copied, e.g. app name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or, if we consider the app name part of the JNDI context, then we should at least change the behavior in ContextSetupProviderimpl.setup(), so that it doesn't try to call isApplicationEnabled if appName is null and automatically considers it as enabled.

I don't know what is better, hm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I resign for now. I reverted this change. I have an idea how to improve the current concurrency runtime and propagate app context if there's no current context but that would be for another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's my idea how to propagate app context if there's none set up: #24544

@OndroMih
Copy link
Contributor Author

The failed test ProgressStatusComplexITest doesn't seem to be related to my changes. Can you please check, @dmatej or restart the build?

3 failures are weird, does it pass locally? mvn clean install -T4C -Pfastest && mvn clean install -pl :admin-tests,:application-tests

I ran just mvn clean install -T4C -Pfastest && mvn clean install -pl :admin-tests locally and the test ProgressStatusComplexITest passed. I had one failure, which again seems to be not related:

 DetachAttachITest.uptimePeriodically:65 » NumberFormat For input string: "Up 1 mins 36 secs"

@OndroMih
Copy link
Contributor Author

OndroMih commented Aug 14, 2023

I ran the whole test suite at night, including the tck, with mvn install -Ptck. I had a few failures, I'm investigating them now. So far, I investigated some failures in the admin-tests module, and all were related to this issue:

java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.exousia.modules.locked.SimplePolicyConfiguration

I sporadically see this error also when I start GlassFish manually, it happens to me maybe 1 out of 100 times. When I restart GlassFish it's fixed. Probably some race condition during startup.

I created an issue for it here: #24543

appName is null by default in concurrent tasks because app context isn't propagated.
This needs to be fixed before appName can be considered not null.
Signed-off-by:Ondro Mihalyi <[email protected]>
@OndroMih OndroMih changed the title Fix: tasks submitted to executor during deployment are executed Tests to verify that tasks submitted to executor during deployment are executed Aug 23, 2023
@arjantijms arjantijms added this to the 7.0.8 milestone Aug 24, 2023
@arjantijms arjantijms merged commit e793b95 into eclipse-ee4j:master Aug 24, 2023
@dmatej
Copy link
Contributor

dmatej commented Aug 28, 2023

DetachAttachITest.uptimePeriodically:65 » NumberFormat For input string: "Up 1 mins 36 secs"

This should not happen, you should receive a job id, not the result. Wasn't it caused by your local changes?

@OndroMih
Copy link
Contributor Author

DetachAttachITest.uptimePeriodically:65 » NumberFormat For input string: "Up 1 mins 36 secs"

This should not happen, you should receive a job id, not the result. Wasn't it caused by your local changes?

Maybe. Everything passes on Jenkins and I think I also ran all the admin tests later and everything passed. So I wouldn't bother with it.

@OndroMih OndroMih deleted the ondromih-executors-during-deployment branch October 29, 2023 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ManagedExecutorService does not execute tasks submitted during application startup
3 participants