killbill / killbill-platform

Kill Bill core platform
https://killbill.io
Apache License 2.0
25 stars 42 forks source link

IllegalStateException : version null cannot be started when installing plugin #161

Open xsalefter opened 7 months ago

xsalefter commented 7 months ago

There's random exception thrown when installing plugin.

2024-03-29T22:00:36,844+0000 lvl='ERROR', log='Bus', th='bus_events-th', xff='', rId='', tok='', aRId='', tRId='0', Exception thrown by subscriber method handleKillbillEvent(org.killbill.billing.notification.plugin.api.ExtBusEvent) on subscriber org.killbill.billing.osgi.OSGIListener@7cc8ae6c when dispatching event: DefaultBusExternalEvent{objectId=null, accountId=null, tenantId=null, objectType=SERVICE_BROADCAST, eventType=BROADCAST_SERVICE}
java.lang.IllegalStateException: Plugin <XXX>-plugin--7997d0 version null cannot be started because the version 1.0.1-7997d04 already exists in the registry (state = 32)
    at org.killbill.billing.osgi.BundleRegistry.installAndStartNewBundle(BundleRegistry.java:74)
    at org.killbill.billing.osgi.OSGIListener.handleKillbillEvent(OSGIListener.java:109)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

This might have something to do with calling various /nodesInfo endpoints (install, start, check at almost the same time) and there's race condition? Need more investigation when this actually happened.

pierre commented 6 days ago

It sounds like this error (not quite the same though: version isn't null):

java.lang.IllegalStateException: Plugin aviate-plugin version 1.0.12 cannot be started because the version 1.0.12-3368e6a already exists in the registry (state = 32)

can happen if the user installs the same plugin with the same version. This should be gracefully handled.

xsalefter commented 5 days ago

Pierre comment above missing the link.

Furthermore, I can reproduce this:

  1. Download plugin (v.1.0.0, for example)
  2. Start v.1.0.0
  3. Resend download command/API call to v.1.0.0
  4. Resend start command/API call v.1.0.0

Note that point 3 and 4 should be called simultaneously.

xsalefter commented 5 days ago

Also, from my post above, calling point 1 and 2 simultaneously:

  1. Download plugin (v.1.0.0)
  2. Start v.1.0.0

Causing the plugin not starting. This can be an issue for client app, where it expect the plugin should be started right after downloaded.

But then again, I have no idea how we handle this properly (since AFAIK, plugin uses PersistantBus and just return 202 immediately)