Commit e7757079 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

essential support for refreshOnly syncrepl

parent ad9f3ebe
......@@ -27,6 +27,10 @@
#include "slap.h"
#include "proto-sql.h"
#ifdef BACKSQL_SYNCPROV
#include <lutil.h>
#endif /* BACKSQL_SYNCPROV */
/*
* Skip:
* - null values (e.g. delete modification)
......@@ -888,6 +892,25 @@ backsql_add( Operation *op, SlapReply *rs )
realndn = BER_BVNULL,
realpdn = BER_BVNULL;
#ifdef BACKSQL_SYNCPROV
/*
* NOTE: fake successful result to force contextCSN to be bumped up
*/
if ( op->o_sync ) {
char buf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
struct berval csn = BER_BVNULL;
slap_get_csn( op, buf, sizeof( buf ), &csn, 1 );
rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
slap_graduate_commit_csn( op );
return 0;
}
#endif /* BACKSQL_SYNCPROV */
Debug( LDAP_DEBUG_TRACE, "==>backsql_add(\"%s\")\n",
op->oq_add.rs_e->e_name.bv_val, 0, 0 );
......
......@@ -88,7 +88,6 @@
* define to enable very extensive trace logging (debug only)
*/
#undef BACKSQL_TRACE
#define BACKSQL_TRACE
/*
* define to enable varchars as unique keys in user tables
......@@ -99,6 +98,13 @@
*/
#undef BACKSQL_ARBITRARY_KEY
/*
* define to enable experimental support for syncporv overlay
*/
#ifdef LDAP_DEVEL
#define BACKSQL_SYNCPROV
#endif /* LDAP_DEVEL */
/*
* define to the appropriate aliasing string
*
......
......@@ -80,12 +80,15 @@ backsql_operational_entryCSN( Operation *op )
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
BER_BVZERO( &a->a_vals[ 1 ] );
#ifdef BACKSQL_SYNCPROV
if ( op->o_sync && op->o_tag == LDAP_REQ_SEARCH ) {
assert( op->o_private );
entryCSN = *((struct berval *)op->o_private);
} else {
} else
#endif /* BACKSQL_SYNCPROV */
{
slap_get_csn( op, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
}
......
......@@ -671,6 +671,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
rc = 1;
goto done;
#ifdef BACKSQL_SYNCPROV
} else if ( ad == slap_schema.si_ad_entryCSN ) {
/*
* TODO: introduce appropriate entryCSN filtering
......@@ -683,9 +684,6 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
goto done;
}
/* save for later use in operational attributes */
bsi->bsi_op->o_private = &f->f_av_value;
bsi->bsi_flags |= ( BSQL_SF_FILTER_ENTRYCSN | BSQL_SF_RETURN_ENTRYUUID);
/* if doing a syncrepl, try to return as much as possible,
......@@ -693,9 +691,21 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)STRLENOF( "1=1" ), "1=1" );
/* save for later use in operational attributes */
/* FIXME: saves only the first occurrence, because
* the filter during updates is written as
* "(&(entryCSN<={contextCSN})(entryCSN>={oldContextCSN})({filter}))"
* so we want our fake entryCSN to match the greatest
* value
*/
if ( bsi->bsi_op->o_private == NULL ) {
bsi->bsi_op->o_private = &f->f_av_value;
}
bsi->bsi_status = LDAP_SUCCESS;
rc = 1;
goto done;
#endif /* BACKSQL_SYNCPROV */
} else if ( ad == slap_schema.si_ad_hasSubordinates || ad == NULL ) {
/*
......@@ -1896,6 +1906,7 @@ backsql_search( Operation *op, SlapReply *rs )
}
}
#ifdef BACKSQL_SYNCPROV
if ( bsi.bsi_flags & BSQL_SF_FILTER_ENTRYCSN ) {
a_entryCSN = backsql_operational_entryCSN( op );
if ( a_entryCSN != NULL ) {
......@@ -1908,6 +1919,7 @@ backsql_search( Operation *op, SlapReply *rs )
*ap = a_entryCSN;
}
}
#endif /* BACKSQL_SYNCPROV */
if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE )
{
......@@ -1970,6 +1982,27 @@ end_of_search:;
rs->sr_v2ref = NULL;
}
#ifdef BACKSQL_SYNCPROV
if ( op->o_sync ) {
Operation op2 = *op;
SlapReply rs2 = { 0 };
Entry e = { 0 };
slap_callback cb = { 0 };
op2.o_tag = LDAP_REQ_ADD;
op2.o_bd = select_backend( &op->o_bd->be_nsuffix[0], 0, 0 );
op2.ora_e = &e;
op2.o_callback = &cb;
e.e_name = op->o_bd->be_suffix[0];
e.e_nname = op->o_bd->be_nsuffix[0];
cb.sc_response = slap_null_cb;
op2.o_bd->be_add( &op2, &rs2 );
}
#endif /* BACKSQL_SYNCPROV */
done:;
if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
(void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment