Skip to content

Commit

Permalink
DAOS-6733 vos: handle resend RPC when original one is not prepared (#…
Browse files Browse the repository at this point in the history
…5213)

To handle the race from DTX refresh, the leader will pre-create
the DTX entry in DRAM before dispatching related modifications.
If such pre-created DTX entry was found by the resent handling
logic before leader prepared related local modifications, then
the server should return "-DER_INPROGRESS" to the client. Then
the modification for actived DTX entry should not happen unless
former abort left stale entry.

Master-PR: #4791

Signed-off-by: Fan Yong <[email protected]>
  • Loading branch information
Nasf-Fan authored Mar 28, 2021
1 parent 9fece3d commit f51691d
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/vos/vos_dtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ enum {
#define DTX_UMOFF_TYPES (DTX_UMOFF_ILOG | DTX_UMOFF_SVT | DTX_UMOFF_EVT)
#define DTX_INDEX_INVAL (int32_t)(-1)

#define dtx_evict_lid(cont, dae) \
do { \
D_DEBUG(DB_TRACE, "Evicting lid "DF_DTI": lid=%d\n", \
DP_DTI(&DAE_XID(dae)), DAE_LID(dae)); \
lrua_evictx(cont->vc_dtx_array, \
DAE_LID(dae) - DTX_LID_RESERVED, \
DAE_EPOCH(dae)); \
} while (0)

static inline void
dtx_type2umoff_flag(umem_off_t *rec, uint32_t type)
{
Expand Down Expand Up @@ -287,18 +296,21 @@ static int
dtx_act_ent_update(struct btr_instance *tins, struct btr_record *rec,
d_iov_t *key, d_iov_t *val)
{
struct vos_container *cont = tins->ti_priv;
struct vos_dtx_act_ent *dae_new = val->iov_buf;
struct vos_dtx_act_ent *dae_old;

dae_old = umem_off2ptr(&tins->ti_umm, rec->rec_off);
if (DAE_EPOCH(dae_old) != DAE_EPOCH(dae_new)) {
D_ASSERTF(!dae_old->dae_prepared,
"NOT allow to update act DTX entry for "DF_DTI
" from epoch "DF_X64" to "DF_X64"\n",
DP_DTI(&DAE_XID(dae_old)),
DAE_EPOCH(dae_old), DAE_EPOCH(dae_new));
return -DER_INPROGRESS;
}

D_ASSERT(dae_old != dae_new);
D_ASSERTF(dae_old->dae_aborted,
"NOT allow to update act DTX entry for "DF_DTI
" from epoch "DF_X64" to "DF_X64"\n",
DP_DTI(&DAE_XID(dae_old)),
DAE_EPOCH(dae_old), DAE_EPOCH(dae_new));

rec->rec_off = umem_ptr2off(&tins->ti_umm, dae_new);
dtx_evict_lid(cont, dae_old);

return 0;
}
Expand Down Expand Up @@ -611,15 +623,6 @@ do_dtx_rec_release(struct umem_instance *umm, struct vos_container *cont,
return rc;
}

#define dtx_evict_lid(cont, dae) \
do { \
D_DEBUG(DB_TRACE, "Evicting lid "DF_DTI": lid=%d\n", \
DP_DTI(&DAE_XID(dae)), DAE_LID(dae)); \
lrua_evictx(cont->vc_dtx_array, \
DAE_LID(dae) - DTX_LID_RESERVED, \
DAE_EPOCH(dae)); \
} while (0)

static int
dtx_rec_release(struct vos_container *cont, struct vos_dtx_act_ent *dae,
bool abort)
Expand Down Expand Up @@ -1762,7 +1765,7 @@ vos_dtx_check(daos_handle_t coh, struct dtx_id *dti, daos_epoch_t *epoch,
if (dae->dae_prepared || !for_resent)
return DTX_ST_PREPARED;

return -DER_NONEXIST;
return -DER_INPROGRESS;
}

if (rc == -DER_NONEXIST) {
Expand Down

0 comments on commit f51691d

Please sign in to comment.