Design Specification: Database Change Event Cache Invalidation
|Date||Author||Version Description & Notes|
Some databases support raising change events when tables are updated or changed. It is also possible in some databases to raise events from triggers, and some third party products support raising database change events.
When a share cache is used in EclipseLink it can become stale if other applications (or other nodes) update the database directly.
This project will provide an infrastructure for supporting database change events to invalidate the changed objects in the EclipseLink shared cache.
Oracle's Database Change event Notification will be supported for Oracle databases.
Oracle DCN : The Oracle database Database Change event Notification feature available since Oracle 10.2.
- Support generic database change event listener.
- Support Oracle DCN
- Support cache invalidation of change objects.
- Must support database events with limited information, such as only the table ROWID.
- Add a DatabaseEventNotificationListener interface and to DatabaseSessionImpl (Database and Server sessions).
- Give register/remove callbacks on login/logout.
- Add OracleDCNListener to Oracle with Oracle JDBC dependencies.
- Register with database on login, remove on logout.
- Oracle DCN only gives table name and ROWID, no primary key, so need to match ROWID with ID.
- Adds a cache index on ROWID to all managed descriptors.
- All objects read will be indexed by ROWID from cache index.
- Add insert callback to select ROWID and index in cache.
- On any update or delete get the transaction id and store in the unit of work properties.
- On merge for updates include the transaction id in the CacheKey
- When a DCN event is received find the CacheKey for the ROWID, and invalidate unless its transaction id matches the events transaction id.
- Add a DatabaseCacheInvalidationPolicy to allow a descriptor to be configured to receive change events.
- Add a persistence unit default property for cache invalidation type.
Add a JPA test model for DCN testing to the Oracle tests. Test:
- multiple tables (with versioning)
- relationships (with versioning)
- ensure objects invalidated in other session
- test native SQL queries
- test update-all queries
- CacheInvalidationType (TimeToLive, Database, Daily, None)
- setDatabaseEventListener(DatabaseEventNotificationListener )
- DatabaseEventNotificationListener (org.eclipse.persistence.platform.database.events)
- OracleDCNListener (org.eclipse.persistence.platform.oracle.dcn)
- persistence.xml - property
Should be documented under caching section.
|Issue #||Owner||Description / Notes|
|Issue||Description / Notes||Decision|