You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Borut Bolčina <bo...@najdi.si> on 2006/07/31 17:52:21 UTC

Database replication and caching

Hello,

I need an advice on using Cayenne in an environment where two PostgeSQL  
databases are configured to replicate from each other for failover 
capability. I am thinking of two Cayenne enabled applications (load 
distribution) which insert records in one of those two databases. 
Application one (A1) inserts in database one (DB1) and application two 
(A2) inserts in database two (DB2).

The insertion, deletion or update will cause Java triggers in PostgreSQL 
to call appropriate Java method in the application. If for any reason 
one of the databases is down for some time, the replication mechanism 
will bring the second database up-to date which will trigger invocations 
of the Java methods, so the second application will be in the correct 
state also.

As long as triggers do not modify records, everything should be ok with 
Cayenne. In case, which I don't foresee now, the records will be 
modified on database level, all DataContexts should be invalidated, am I 
right?

Is there any other (caching) problem you see in this architecture?

Regards,
Borut


Re: Database replication and caching

Posted by Andrus Adamchik <an...@objectstyle.org>.
A shared cache can be cleaned up by doing  
DataDomain.getSharedSnapshotCache().clear(). Also I am in the process  
of implementing a pluggable externally managed cache in 3.0:

http://issues.apache.org/cayenne/browse/CAY-613

Andrus



On Aug 2, 2006, at 2:41 AM, Borut Bolčina wrote:

> We are at architectural/design phase (cycle zero). No decision has  
> yet been made. Is there an example for invalidating cache somewhere?
>
> bye,
> Borut
>
> On 31.7.2006 20:29, Tore Halset wrote:
>> Hello.
>>
>> On Jul 31, 2006, at 17:52, Borut Bolčina wrote:
>>
>>> I need an advice on using Cayenne in an environment where two  
>>> PostgeSQL  databases are configured to replicate from each other  
>>> for failover capability.
>>
>> Are you using Sequoia[1] or slony[2] or creating your own solution?
>>
>>> I am thinking of two Cayenne enabled applications (load  
>>> distribution) which insert records in one of those two databases.  
>>> Application one (A1) inserts in database one (DB1) and  
>>> application two (A2) inserts in database two (DB2).
>>>
>>> The insertion, deletion or update will cause Java triggers in  
>>> PostgreSQL to call appropriate Java method in the application. If  
>>> for any reason one of the databases is down for some time, the  
>>> replication mechanism will bring the second database up-to date  
>>> which will trigger invocations of the Java methods, so the second  
>>> application will be in the correct state also.
>>>
>>> As long as triggers do not modify records, everything should be  
>>> ok with Cayenne. In case, which I don't foresee now, the records  
>>> will be modified on database level, all DataContexts should be  
>>> invalidated, am I right?
>>
>> Cayenne has its own way of syncronizing cache[3] between app  
>> instances. You could also invalidate cache manually.
>>
>>  - Tore.
>>
>> [1] http://sequoia.continuent.org/HomePage
>> [2] http://gborg.postgresql.org/project/slony1/
>> [3] http://cwiki.apache.org/CAYDOC/configuring-caching-behavior.html
>>
>>
>
> -- 
> <blog-logo.gif>
>
> --
> Naključna izjava tedna iz tednika Mladina:


Re: Database replication and caching

Posted by Borut Bolčina <bo...@najdi.si>.
We are at architectural/design phase (cycle zero). No decision has yet 
been made. Is there an example for invalidating cache somewhere?

bye,
Borut

On 31.7.2006 20:29, Tore Halset wrote:
> Hello.
>
> On Jul 31, 2006, at 17:52, Borut Bolčina wrote:
>
>> I need an advice on using Cayenne in an environment where two 
>> PostgeSQL  databases are configured to replicate from each other for 
>> failover capability.
>
> Are you using Sequoia[1] or slony[2] or creating your own solution?
>
>> I am thinking of two Cayenne enabled applications (load distribution) 
>> which insert records in one of those two databases. Application one 
>> (A1) inserts in database one (DB1) and application two (A2) inserts 
>> in database two (DB2).
>>
>> The insertion, deletion or update will cause Java triggers in 
>> PostgreSQL to call appropriate Java method in the application. If for 
>> any reason one of the databases is down for some time, the 
>> replication mechanism will bring the second database up-to date which 
>> will trigger invocations of the Java methods, so the second 
>> application will be in the correct state also.
>>
>> As long as triggers do not modify records, everything should be ok 
>> with Cayenne. In case, which I don't foresee now, the records will be 
>> modified on database level, all DataContexts should be invalidated, 
>> am I right?
>
> Cayenne has its own way of syncronizing cache[3] between app 
> instances. You could also invalidate cache manually.
>
>  - Tore.
>
> [1] http://sequoia.continuent.org/HomePage
> [2] http://gborg.postgresql.org/project/slony1/
> [3] http://cwiki.apache.org/CAYDOC/configuring-caching-behavior.html
>
>

-- 
bLOG <http://www.delo.si/blog/borutb/>
--
Naključna *izjava tedna* iz tednika Mladina:

Re: Database replication and caching

Posted by Tore Halset <ha...@pvv.ntnu.no>.
Hello.

On Jul 31, 2006, at 17:52, Borut Bolčina wrote:

> I need an advice on using Cayenne in an environment where two  
> PostgeSQL  databases are configured to replicate from each other  
> for failover capability.

Are you using Sequoia[1] or slony[2] or creating your own solution?

> I am thinking of two Cayenne enabled applications (load  
> distribution) which insert records in one of those two databases.  
> Application one (A1) inserts in database one (DB1) and application  
> two (A2) inserts in database two (DB2).
>
> The insertion, deletion or update will cause Java triggers in  
> PostgreSQL to call appropriate Java method in the application. If  
> for any reason one of the databases is down for some time, the  
> replication mechanism will bring the second database up-to date  
> which will trigger invocations of the Java methods, so the second  
> application will be in the correct state also.
>
> As long as triggers do not modify records, everything should be ok  
> with Cayenne. In case, which I don't foresee now, the records will  
> be modified on database level, all DataContexts should be  
> invalidated, am I right?

Cayenne has its own way of syncronizing cache[3] between app  
instances. You could also invalidate cache manually.

  - Tore.

[1] http://sequoia.continuent.org/HomePage
[2] http://gborg.postgresql.org/project/slony1/
[3] http://cwiki.apache.org/CAYDOC/configuring-caching-behavior.html



Re: Database replication and caching

Posted by Borut Bolčina <bo...@najdi.si>.
Oh, I forgot to mention that PK generation will be completely handled 
outside Cayenne, so PK (oid) will be just another db attribute. It is 
guaranteed, that insert will be done with different PKs at each 
concurrent running applications.

Gentry, Michael (Contractor) pravi:
> I'm not familiar with PostgreSQL's replication capabilities, but I'd be
> concerned about primary key duplication and possible data loss (this
> would be outside of Cayenne's control).  For example, what would happen
> if both applications ran the sequence to generate PKs at the same time?
>
>
> -----Original Message-----
> From: Borut Bolcina [mailto:bob@najdi.si] 
> Sent: Monday, July 31, 2006 11:52 AM
> To: cayenne-user
> Subject: Database replication and caching
>
>
> Hello,
>
> I need an advice on using Cayenne in an environment where two PostgeSQL
>
> databases are configured to replicate from each other for failover 
> capability. I am thinking of two Cayenne enabled applications (load 
> distribution) which insert records in one of those two databases. 
> Application one (A1) inserts in database one (DB1) and application two 
> (A2) inserts in database two (DB2).
>
> The insertion, deletion or update will cause Java triggers in PostgreSQL
>
> to call appropriate Java method in the application. If for any reason 
> one of the databases is down for some time, the replication mechanism 
> will bring the second database up-to date which will trigger invocations
>
> of the Java methods, so the second application will be in the correct 
> state also.
>
> As long as triggers do not modify records, everything should be ok with 
> Cayenne. In case, which I don't foresee now, the records will be 
> modified on database level, all DataContexts should be invalidated, am I
>
> right?
>
> Is there any other (caching) problem you see in this architecture?
>
> Regards,
> Borut
>
>   


RE: Database replication and caching

Posted by "Gentry, Michael (Contractor)" <mi...@fanniemae.com>.
I'm not familiar with PostgreSQL's replication capabilities, but I'd be
concerned about primary key duplication and possible data loss (this
would be outside of Cayenne's control).  For example, what would happen
if both applications ran the sequence to generate PKs at the same time?


-----Original Message-----
From: Borut Bolcina [mailto:bob@najdi.si] 
Sent: Monday, July 31, 2006 11:52 AM
To: cayenne-user
Subject: Database replication and caching


Hello,

I need an advice on using Cayenne in an environment where two PostgeSQL

databases are configured to replicate from each other for failover 
capability. I am thinking of two Cayenne enabled applications (load 
distribution) which insert records in one of those two databases. 
Application one (A1) inserts in database one (DB1) and application two 
(A2) inserts in database two (DB2).

The insertion, deletion or update will cause Java triggers in PostgreSQL

to call appropriate Java method in the application. If for any reason 
one of the databases is down for some time, the replication mechanism 
will bring the second database up-to date which will trigger invocations

of the Java methods, so the second application will be in the correct 
state also.

As long as triggers do not modify records, everything should be ok with 
Cayenne. In case, which I don't foresee now, the records will be 
modified on database level, all DataContexts should be invalidated, am I

right?

Is there any other (caching) problem you see in this architecture?

Regards,
Borut