basex icon indicating copy to clipboard operation
basex copied to clipboard

ServerCommandTest: Occasional failures

Open ChristianGruen opened this issue 9 months ago • 1 comments

One of the tests seems to fail occasionally:

Error:  Errors: 
Error:    ServerCommandTest>CommandTest.after:65->CommandTest.cleanUp:57 » BaseX User 'Sandbox2' is logged in.

ChristianGruen avatar Apr 02 '25 17:04 ChristianGruen

The failure occurs in ServerCommandTest.kill. An actual occurrence of it looks like this:

Error:  Tests run: 44, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.293 s <<< FAILURE! -- in org.basex.core.ServerCommandTest
Error:  org.basex.core.ServerCommandTest.kill -- Time elapsed: 0.009 s <<< ERROR!
org.basex.core.BaseXException: 
User 'Sandbox2' is logged in.

	at org.basex.api.client.ClientSession.receive(ClientSession.java:190)
	at org.basex.api.client.ClientSession.execute(ClientSession.java:160)
	at org.basex.api.client.ClientSession.execute(ClientSession.java:165)
	at org.basex.api.client.Session.execute(Session.java:36)
	at org.basex.core.CommandTest.cleanUp(CommandTest.java:57)
	at org.basex.core.CommandTest.after(CommandTest.java:65)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

The failure is detected when the @AfterEach method after() invokes cleanUp() after ServerCommandTest.kill has completed, as follows: cleanUp calls session.execute(new DropUser("Sandbox2")), and DropUser.run(String, String) finds an unexpected ClientListener for user Sandbox2 in context.getSessions().

The ClientListener would have been removed from Context.sessions by ClientListener.close(), which has multiple chances to get invoked:

  1. usually from Kill.run(String, String):60 called for ServerCommandTest.kill():58
  2. additionally in several places in ClientListener.run(), which is called by ClientSession.close() on behalf of the try-with-resource in ServerCommandTest.kill():57

I have no explanation yet how all of those can be bypassed silently, such that the ClientListener remains in Context.sessions.

GuntherRademacher avatar Apr 08 '25 06:04 GuntherRademacher

Discarded; difficult to reproduce.

ChristianGruen avatar Jul 01 '25 13:07 ChristianGruen