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

Ask Your Question
0

Mirror Service question

Hello,

I had working Writing Asynchronously to Mirror Data Source configuration based on _partitioned-sync2backup_ schema [ http://www.gigaspaces.com/wiki/displa... ]

Now I'm switching to Partitioning Over Central Mirror Data Source and I started to have issues...

1) all starting to be too slowly 2) mirror stopping to work (or also too slow)

I'm using GigaSpacesXAP6.0 Persistence is based on Hibernate

I'm using PU with _pu.xml_ My changes are: comment 1st line and uncomment 2nd

<os-core:space id="miwokGrid" url="/./miwokGrid" lookup-groups="gigaspaces-6.0XAP"/>

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

_hibernateDataSource_ defined in this pu.xml as...

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.postgresql.Driver"/> <property name="url" value="jdbc:postgresql://localhost/mirror"/> <property name="username" value="postgres"/> <property name="password" value="postgres"/> </bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="useTransactionAwareDataSource" value="true"/> <property name="mappingResources"> <list> ... <value>com/miwok/model/gs/Person.hbm.xml</value> ... </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">false</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="show_sql">true</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.cglib.use_reflection_optimizer">false</prop> <prop key="hibernate.jdbc.use_streams_for_binary">true</prop> </props> </property> </bean>

<bean id="hibernateDataSource" class="com.gigaspaces.datasource.hibernate.HibernateDataSource"> <property name="sessionFactory" ref="sessionFactory"/> </bean>

Schema _persistent-readonly_ is original _persistent_ schema but: + <usage>read-only</usage>

Schema _partitioned-sync2backup-mirror-readonly_ is original _partitioned-sync2backup_ schema but: + <mirror-service> <enabled>true</enabled>

  • <cache-loader> <external-data-source>true</external-data-source> <central-data-source>true</central-data-source> </cache-loader>

Maybe I did something wrong ? Could You please provide me some some best practise in this area ?

Thanks, illya

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2426]{quote}

asked 2008-06-28 14:12:14 -0500

illya77 gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Seems as a problem with the initialLoad. Can you switch to the org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource and test? Shay

answered 2008-06-29 08:33:09 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

Here are few suggestions when using this topology ( Mirror + Partitioned + Backup + External Data Source in read only Usage mode): - The most important suggestion would be: Move to 6.5 and use the new open spaces Hibernate data source provided.

There are 2 options: org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource org.openspaces.persistency.hibernate.StatelessHibernateExternalDataSource

See the JavaDoc for details.

The old com.gigaspaces.datasource.hibernate.HibernateDataSource has been deprecated with 6.5 and replaced with much better implementation.

  • Run in ALL_IN_CACHE to load all the data into the spaces and not to use LRU that got some limitations when it comes to queries.

  • In case you have very large database - Make sure each partition will load its own data set and not load all the data that will be later filter out based on the routing field value. This means you will need to perform a query that will look like this as part of the initialLoad implementation (override the relevant HibernateExternalDataSource class):

Select * from Person where "MOD(PERSON_ID," + numberOfPartitions + ") = " + (partitionNumber -1)

See more details here: http://www.gigaspaces.com/wiki/displa...

  • Don't to use like or rlike SQL queries against the space. These are very expensive operations. These should be delegated to the database directly via Remote services (use open spaces remoting) or via dedicated partition which running in LRU and does not cache any data.

  • Tune your Mirror service database JDBC connection to be optimized for batch operations.

  • If you are using 6.0 and have large data set loaded make sure to increase the cluster repl-find-timeout parameter to have large value - make it large enough allowing the primary to load its data before the backup gives up to connect the primary (it will move itself to stopped mode with too small timeout).

  • Since in central data source mode write operations will not be replicated from the primary to the backup , use non central data source mode. This will allow the primary to replicate data into the primary having the data available in the backup after a fail over.

Shay

answered 2008-06-29 00:27:11 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Shai,

when I switched to GS 6.5 I start getting next exception during pudeploy. I have the same exception even when I use _sync_replicated_ schema (previously was _partitioned-sync2backup_)

Maybe I need update hibernate or smth like this

Thanks, illya


com.j_spaces.core.CreateException: Failed to init [miwokGrid] space. org.hiberna te.NonUniqueResultException: query did not return a unique result: 2 at com.j_spaces.obf.pv.a(SourceFile:903) at com.j_spaces.core.JSpaceImpl.B(SourceFile:3484) at com.j_spaces.core.JSpaceImpl.y(SourceFile:3362) at com.j_spaces.core.JSpaceImpl.start(SourceFile:3163) at com.j_spaces.core.JSpaceImpl.<init>(SourceFile:366) at com.j_spaces.core.JSpaceImpl.<init>(SourceFile:306) at com.j_spaces.core.JSpaceContainerImpl.a(SourceFile:2921) at com.j_spaces.core.JSpaceContainerImpl.a(SourceFile:2844) at com.j_spaces.core.JSpaceContainerImpl.bj(SourceFile:1286) at com.j_spaces.core.JSpaceContainerImpl.bc(SourceFile:681) at com.j_spaces.core.JSpaceContainerImpl.<init>(SourceFile:576) at com.j_spaces.core.client.SpaceFinder.a(SourceFile:769) at com.j_spaces.core.client.SpaceFinder.a(SourceFile:888) at com.j_spaces.core.client.SpaceFinder._find(SourceFile:612) at com.j_spaces.core.client.SpaceFinder.internalFind(SourceFile:412) at com.j_spaces.core.client.SpaceFinder.internalFind(SourceFile:387) at com.j_spaces.core.client.SpaceFinder.find(SourceFile:206) at org.openspaces.core.space.UrlSpaceFactoryBean.doCreateSpace(UrlSpaceFactoryBean.java:286) at org.openspaces.core.space.AbstractSpaceFactoryBean.afterPropertiesSet(AbstractSpaceFactoryBean.java:136) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:948) at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:702) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:378) at org.openspaces.pu.container.integrated.IntegratedProcessingUnitContainerProvider.createContainer(IntegratedProcessingUnitContainerProvider.java:237) at org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.startPU(PUServiceBeanImpl.java:205) at org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.advertise(PUServiceBeanImpl.java:120) at org.jini.rio.resources.servicecore.ServiceAdminImpl.advertise(ServiceAdminImpl.java:214) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.gigaspaces.lrmi.DynamicSmartStub._invoke(SourceFile:208) at com.gigaspaces.lrmi.DynamicSmartStub.invokeDirect(SourceFile:290) at com.gigaspaces.lrmi.DynamicSmartStub.invoke(SourceFile:348) at $Proxy13.advertise(Unknown Source) at org.jini.rio.resources.servicecore.ServiceAdminProxy.advertise(ServiceAdminProxy.java:114) at ...

(more)
illya77 gravatar imageillya77 ( 2008-06-29 04:05:19 -0500 )edit

Hello Shay Banon,

You are right. That's because of my data model... I had:

@SpaceClass public class GSBaseObject implements Serializable { protected Long id=null;

@SpaceId(autoGenerate=false)
public Long getId() {
    return id;
}

public void setId(Long uid) {
    this.id = uid;
}

}

public class Person extends GSBaseObject { ... }

public class User extends Person { ... }

By historical reasons both Person and User were mapped to DB by Hibernate to different tables PERSON, USER

I disable parent class Person mapping and all started to be Ok

Thanks, illya

illya77 gravatar imageillya77 ( 2008-06-30 03:04:03 -0500 )edit

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: 2008-06-28 14:12:14 -0500

Seen: 97 times

Last updated: Jun 29 '08