Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WAN replication of IMap/ICache evictions (#24941) [5.3.z] #25039

Merged
merged 3 commits into from
Jul 21, 2023

Conversation

JamesHazelcast
Copy link
Contributor

@JamesHazelcast JamesHazelcast commented Jul 19, 2023

Backport of: #24941

In the current implementation of Hazelcast, evictions are not replicated over WAN to target clusters - this is done intentionally as evictions are purely local operations that usually occur as a last resort to free resources on demand. However, there are circumstances where some users may want to have evictions replicated over WAN to try and maintain more synchronization between 2 clusters (even though this does still not guarantee data consistency using WAN).

This commit introduces 2 new ClusterProperty entries that allow WAN replication of IMap and ICache eviction events respectively. This property is disabled by default and must be explicitly enabled as WAN replication of eviction events was purposefully omitted prior to this.

Code changes are simple, introducing publishWanRemove() calls within DefaultRecordStore (for IMap) and AbstractCacheRecordStore (for ICache) - I had originally trialed a solution that introduced these calls within operations (EvictOperation etc) to match existing WAN replication mechanics, but due to the mostly-local nature of eviction that is often triggered as a result of other operations (not eviction operations directly), it made more sense to implement at the root of eviction calls, which resides in these record stores.

This solution, when enabled, fires WAN replication events for all evictions (expiration, resource constraints, user-invoked, etc) - the reason for this is the use-case for these config options is to attempt to keep data more consistent between 2 clusters over WAN, and so in this scenario (although still not bulletproof by any means), it makes sense to try and replicate all operations that result in mutation (as is the case with all evictions).

This commit also includes a regression test that confirms consistency between 2 clusters under ideal circumstances with evictions on the source cluster.

Fixes https://hazelcast.atlassian.net/browse/HZ-2619
EE PR: https://github.com/hazelcast/hazelcast-enterprise/pull/6260

Backport of: hazelcast#24941

In the current implementation of Hazelcast, evictions are not replicated
over WAN to target clusters - this is done intentionally as evictions
are purely local operations that usually occur as a last resort to free
resources on demand. However, there are circumstances where some users
may want to have evictions replicated over WAN to try and maintain more
synchronization between 2 clusters (even though this does still not
guarantee data consistency using WAN).

This commit introduces 2 new `ClusterProperty` entries that allow WAN
replication of `IMap` and `ICache` eviction events respectively. This
property is disabled by default and must be explicitly enabled as WAN
replication of eviction events was purposefully omitted prior to this.

Code changes are simple, introducing `publishWanRemove()` calls within
`DefaultRecordStore` (for `IMap`) and `AbstractCacheRecordStore` (for
`ICache`) - I had originally trialed a solution that introduced these
calls within operations (`EvictOperation` etc) to match existing WAN
replication mechanics, but due to the mostly-local nature of eviction
that is often triggered as a result of other operations (not eviction
operations directly), it made more sense to implement at the root of
eviction calls, which resides in these record stores.

This solution, when enabled, fires WAN replication events for all
evictions (expiration, resource constraints, user-invoked, etc) - the
reason for this is the use-case for these config options is to attempt to
keep data more consistent between 2 clusters over WAN, and so in this
scenario (although still not bulletproof by any means), it makes sense to
try and replicate all operations that result in mutation (as is the case
with all evictions).

This commit also includes a regression test that confirms consistency
between 2 clusters under ideal circumstances with evictions on the source
cluster.

Fixes https://hazelcast.atlassian.net/browse/HZ-2619
Copy link
Contributor

@vbekiaris vbekiaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @JamesHazelcast , just a minor update to the @since version tag needed

JamesHazelcast and others added 2 commits July 19, 2023 16:30
Co-authored-by: Vassilis Bekiaris <vbekiaris@gmail.com>
Co-authored-by: Vassilis Bekiaris <vbekiaris@gmail.com>
@JamesHazelcast
Copy link
Contributor Author

thanks @JamesHazelcast , just a minor update to the @since version tag needed

Good catch, thanks @vbekiaris 👍

@JamesHazelcast JamesHazelcast merged commit 48953b8 into hazelcast:5.3.z Jul 21, 2023
8 checks passed
@AyberkSorgun AyberkSorgun modified the milestones: 5.3.z, 5.3.2 Aug 15, 2023
@JamesHazelcast JamesHazelcast deleted the hz-2619-backport-5.3.z branch September 21, 2023 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants