Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Exception during scheduled task execution in backup-space

I have an issue with scheduled tasks execution in space. Task collocated with space. Configuration of my task is

<bean id="removeOldPostsTask" class="com.afrunt.gs.task.RemoveOldPostsTask" />

<bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
        <!-- wait 1 seconds before starting repeated execution -->
        <property name="delay" value="5000"/>
        <!-- run every minute to show that it's work -->
        <property name="period" value="3600000"/>
<property name="timerTask" ref="removeOldPostsTask"/>

</bean>

<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
        <property name="scheduledTimerTasks">
            <list>
                <!-- This wires the factory to the scheduledTask bean above -->
                <ref bean="scheduledTask"/>
            </list>
        </property>
</bean>

<os-sla:sla number-of-instances="2" cluster-schema="partitioned-sync2backup" max-instances-per-vm="1" number-of-backups="1"/>

After space PU is deployed I receive the exception shown below:

gsc2/3040 Exception in thread "timerFactory" org.openspaces.core.RemoteDataAccessException: container11:GS-Cert-Space">GS-Cert-Spacecontainer11:GS-Cert-Space servers as backup-only space and can't accept any operation while primary container1:GS-Cert-Space">GS-Cert-Spacecontainer1:GS-Cert-Space space is alive.; nested exception is com.gigaspaces.cluster.activeelection.InactiveSpaceException: container11:GS-Cert-Space">GS-Cert-Spacecontainer11:GS-Cert-Space servers as backup-only space and can't accept any operation while primary container1:GS-Cert-Space">GS-Cert-Spacecontainer1:GS-Cert-Space space is alive.
gsc2/3040 at org.openspaces.core.exception.DefaultExceptionTranslator.internalTranslate(DefaultExceptionTranslator.java:108)
gsc2/3040 at org.openspaces.core.exception.DefaultExceptionTranslator.translate(DefaultExceptionTranslator.java:49)
gsc2/3040 at org.openspaces.core.DefaultGigaSpace.count(DefaultGigaSpace.java:243)
gsc2/3040 at org.openspaces.core.DefaultGigaSpace.count(DefaultGigaSpace.java:236)
gsc2/3040 at com.afrunt.gs.task.RemoveOldPostsTask.run(RemoveOldPostsTask.java:30)
gsc2/3040 at java.util.TimerThread.mainLoop(Timer.java:512)
gsc2/3040 at java.util.TimerThread.run(Timer.java:462)
gsc2/3040 Caused by: com.gigaspaces.cluster.activeelection.InactiveSpaceException: container11:GS-Cert-Space">GS-Cert-Spacecontainer11:GS-Cert-Space servers as backup-only space and can't accept any operation while primary container1:GS-Cert-Space">GS-Cert-Spacecontainer1:GS-Cert-Space space is alive.
gsc2/3040 at com.gigaspaces.internal.server.space.SpaceImpl.throwInactiveSpaceException(SpaceImpl.java:671)
gsc2/3040 at com.gigaspaces.internal.server.space.SpaceImpl.checkStateIncludingStandby(SpaceImpl.java:628)
gsc2/3040 at com.gigaspaces.internal.server.space.SpaceImpl.beginPacketOperation(SpaceImpl.java:514)
gsc2/3040 at com.gigaspaces.internal.server.space.SpaceImpl.count(SpaceImpl.java:2275)
gsc2/3040 at com.gigaspaces.internal.lrmi.stubs.LRMISpaceImpl.count(LRMISpaceImpl.java:222)
gsc2/3040 at com.gigaspaces.internal.client.spaceproxy.SpaceProxyImpl.internalCount(SpaceProxyImpl.java:2114)
gsc2/3040 at com.gigaspaces.internal.client.spaceproxy.SpaceProxyImpl.countBasic(SpaceProxyImpl.java:2076)
gsc2/3040 at com.gigaspaces.internal.client.spaceproxy.actions.SpaceProxyImplCountClearAction.count(SpaceProxyImplCountClearAction.java:52)
gsc2/3040 at com.gigaspaces.internal.client.spaceproxy.actions.SpaceProxyImplCountClearAction.count(SpaceProxyImplCountClearAction.java:23)
gsc2/3040 at com.gigaspaces.internal.client.spaceproxy.actions.AbstractSpaceProxyActionManager.count(AbstractSpaceProxyActionManager.java:145)
gsc2/3040 at com.gigaspaces.internal.client.spaceproxy.AbstractSpaceProxy.count(AbstractSpaceProxy.java:162)
gsc2/3040 at org.openspaces.core.DefaultGigaSpace.count(DefaultGigaSpace.java:241)
gsc2/3040 ... 4 more

Any idea how to solve this problem? Or we cannot deploy the scheduled task to space?

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2012-11-26 08:24:05 -0500

afrunt gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

You are injecting a collocated space proxy into the PU where the scheduled task running both on primary and backup partitions.
You should have the scheduled task started within a method that is decorated with @PostPrimary to make sure it will be running only on primary instances.

Another solution would be to run this on a separate PU that is using a remote proxy.

Shay

answered 2012-11-26 09:41:55 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-11-26 08:24:05 -0500

Seen: 576 times

Last updated: Nov 26 '12