[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: followup for ITS#1575



Jong,

Needs a bit of tweaking to avoid write contention on the
global string (bdb_gid_str).

Only the UUID should be in the global string (uuid_str).
Then this string, the connection id, and operation id needs
to be copied into the local string (id_str).

Can you work up a quick patch?

Kurt

At 03:36 PM 2002-02-05, jongchoi@us.ibm.com wrote:
>a patch for bdb_gid generation.
>bdb_gid is generated from uuid_generate(), connection id and operation id.
>- Jong
>
>------------------------
>Jong Hyuk Choi
>IBM Thomas J. Watson Research Center - Enterprise Linux Group
>P. O. Box 218, Yorktown Heights, NY 10598
>email: jongchoi@us.ibm.com
>(phone) 914-945-3979    (fax) 914-945-4425   TL: 862-3979
>
>
>==============================================================================
>
>diff -Naur ldap-head-Feb04/configure ldap-head-Feb04new/configure
>--- ldap-head-Feb04/configure Wed Jan 30 00:31:44 2002
>+++ ldap-head-Feb04new/configure    Mon Feb  4 15:57:28 2002
>@@ -2651,7 +2651,7 @@
> LDBM_LIB=
> LDBM_LIBS=
> LTHREAD_LIBS=
>-LUTIL_LIBS=
>+LUTIL_LIBS=-luuid
>
> SLAPD_LIBS=
> SLURPD_LIBS=
>diff -Naur ldap-head-Feb04/configure.in ldap-head-Feb04new/configure.in
>--- ldap-head-Feb04/configure.in    Wed Jan 30 00:21:10 2002
>+++ ldap-head-Feb04new/configure.in Mon Feb  4 15:57:34 2002
>@@ -475,7 +475,7 @@
> LDBM_LIB=
> LDBM_LIBS=
> LTHREAD_LIBS=
>-LUTIL_LIBS=
>+LUTIL_LIBS=-luuid
>
> SLAPD_LIBS=
> SLURPD_LIBS=
>diff -Naur ldap-head-Feb04/servers/slapd/back-bdb/add.c
>ldap-head-Feb04new/servers/slapd/back-bdb/add.c
>--- ldap-head-Feb04/servers/slapd/back-bdb/add.c      Sat Feb  2 02:28:32
>2002
>+++ ldap-head-Feb04new/servers/slapd/back-bdb/add.c   Mon Feb  4 16:35:00
>2002
>@@ -13,8 +13,6 @@
> #include "back-bdb.h"
> #include "external.h"
>
>-static char bdb_gid[DB_XIDDATASIZE];
>-
> int
> bdb_add(
>      BackendDB   *be,
>@@ -39,9 +37,16 @@
>      u_int32_t   lockid;
>      DB_LOCK           lock;
> #endif
>+     char        id_str[20];
>
>      Debug(LDAP_DEBUG_ARGS, "==> bdb_add: %s\n", e->e_dn, 0, 0);
>
>+     /* get global transaction id */
>+     bdb_gid_str[36] = '\0';
>+     sprintf(id_str, "-%08x-%08x", conn->c_connid, op->o_opid);
>+     strncat(bdb_gid_str, id_str,
>+           DB_XIDDATASIZE-strlen(bdb_gid_str)-strlen(id_str)-1);
>+
>      /* check entry's schema */
>      rc = entry_schema_check( be, e, NULL, &text, textbuf, textlen );
>      if ( rc != LDAP_SUCCESS ) {
>@@ -360,7 +365,7 @@
>            }
>
>      } else {
>-           if (( rc=TXN_PREPARE( ltid, bdb_gid )) != 0 ) {
>+           if (( rc=TXN_PREPARE( ltid, bdb_gid_str )) != 0 ) {
>                  text = "txn_prepare failed";
>
>            } else {
>diff -Naur ldap-head-Feb04/servers/slapd/back-bdb/external.h
>ldap-head-Feb04new/servers/slapd/back-bdb/external.h
>--- ldap-head-Feb04/servers/slapd/back-bdb/external.h Fri Jan  4 20:17:49
>2002
>+++ ldap-head-Feb04new/servers/slapd/back-bdb/external.h    Mon Feb  4
>15:39:40 2002
>@@ -39,7 +39,10 @@
> extern BI_tool_entry_put     bdb_tool_entry_put;
> extern BI_tool_entry_reindex bdb_tool_entry_reindex;
>
>-
>+/* init.c */
>+#include <uuid/uuid.h>
>+extern uuid_t    bdb_gid;
>+extern char      bdb_gid_str[];
>
> LDAP_END_DECL
>
>diff -Naur ldap-head-Feb04/servers/slapd/back-bdb/init.c
>ldap-head-Feb04new/servers/slapd/back-bdb/init.c
>--- ldap-head-Feb04/servers/slapd/back-bdb/init.c     Sat Feb  2 05:25:05
>2002
>+++ ldap-head-Feb04new/servers/slapd/back-bdb/init.c  Mon Feb  4 15:40:04
>2002
>@@ -30,6 +30,9 @@
>      { NULL, NULL, 0, 0 }
> };
>
>+uuid_t     bdb_gid;
>+char bdb_gid_str[DB_XIDDATASIZE];
>+
> #if 0
> static int
> bdb_destroy( BackendInfo *bi )
>@@ -491,6 +494,12 @@
>
>      bi->bi_connection_init = 0;
>      bi->bi_connection_destroy = 0;
>+
>+     /*
>+      * uuid generate
>+      */
>+     (void) uuid_generate(bdb_gid);
>+        (void) uuid_unparse(bdb_gid, bdb_gid_str);
>
>      return 0;
> }
>diff -Naur ldap-head-Feb04/servers/slapd/back-bdb/modrdn.c
>ldap-head-Feb04new/servers/slapd/back-bdb/modrdn.c
>--- ldap-head-Feb04/servers/slapd/back-bdb/modrdn.c   Sat Feb  2 02:28:32
>2002
>+++ ldap-head-Feb04new/servers/slapd/back-bdb/modrdn.c      Mon Feb  4
>16:35:08 2002
>@@ -13,8 +13,6 @@
> #include "back-bdb.h"
> #include "external.h"
>
>-static char bdb_gid[DB_XIDDATASIZE];
>-
> int
> bdb_modrdn(
>      Backend     *be,
>@@ -57,10 +55,18 @@
>
>      int         manageDSAit = get_manageDSAit( op );
>
>+     char        id_str[20];
>+
>      Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n",
>            dn->bv_val, newrdn->bv_val,
>            newSuperior ? newSuperior->bv_val : "NULL" );
>
>+     /* get global transaction id */
>+     bdb_gid_str[36] = '\0';
>+     sprintf(id_str, "-%08x-%08x", conn->c_connid, op->o_opid);
>+     strncat(bdb_gid_str, id_str,
>+           DB_XIDDATASIZE-strlen(bdb_gid_str)-strlen(id_str)-1);
>+
> #if 0
>      if( newSuperior != NULL ) {
>            rc = LDAP_UNWILLING_TO_PERFORM;
>@@ -631,7 +637,7 @@
>            }
>
>      } else {
>-           if(( rc=TXN_PREPARE( ltid, bdb_gid )) != 0 ) {
>+           if(( rc=TXN_PREPARE( ltid, bdb_gid_str )) != 0 ) {
>                  text = "txn_prepare failed";
>            } else {
>                  if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) {