rht_fini is used to "shut
down" a replica, reclaim some of its resources
and mark its handle as invalid when you are done with
it.
rht_fini forces the replica r to
disconnect from Spread (if it has not already due to
permanent errors) and causes any threads in RHT functions
on this replica to return quickly -- some of these threads
may return a RHT_INVALID_HANLDE error.
At about the time the caller enters rht_fini,
all subsequent RHT calls on this replica handle will
fail with a RHT_INVALID_HANDLE error.
You may call rht_fini on a replicant handle
at any time and as many times as you wish! Only the
first such call will have any effect. This can reduce
the thread synchronization headache caused when multiple
threads share a single replica: any/all of these threads
can call rht_fini at any time and the other
threads will "safely" receive RHT_INVALID_HANDLE
errors, indicating that this replica is no longer valid.
To reclaim ALL of the resources associated with a given
replica you need to call rht_fini on the replicant
handle AND rht_snap_fini
on any existing valid snapshots taken of the replica.
Once these conditions are met and all threads have left
RHT procedures on the replica, its on_trash_cb
will fire.
Use of the default RHT_DIRTY_READ flag will cause the
shut down to occur immediately without waiting for any
locally generated updates to be applied. Whereas, specifying
the RHT_CLEAN_READ will first apply all locally generated
updates, and then shut down the replica.
Note, that key-value pair entries from a replica will
continue to persist until you call rht_pair_fini
on any rht_pair you still have from that replica.
As you perform each of these operations the amount of
resources consumed is reduced. |