s4-drepl: Make refreshed schema a global one
authorKamen Mazdrashki <kamenim@samba.org>
Thu, 16 Dec 2010 20:31:28 +0000 (22:31 +0200)
committerKamen Mazdrashki <kamenim@samba.org>
Sat, 18 Dec 2010 03:32:14 +0000 (05:32 +0200)
We need to do this as dsdb_reference_schema() function
clears "use_global_schema" ldb flag.

Basically what is going to happen is that after dsdb_reference_schema()
global_schema pointer will continue to point at old schema cache,
while "dsdb_schema" for LDB will point at the working_schema.

After replication is done, we reset "dsdb_schema" for the ldb
with an updated Schema cache, but this leaves global_schema pointer
with its old value, which is not up to date.
So we need to call dsdb_make_schema_global() again so that global_schema
points to a valid Schema cache.

source4/dsdb/repl/replicated_objects.c

index d01d3c1e7f4fc2d4e0c99c966880d4f0a6770264..5997073a8a2907867fd3878a733a478acc60394f 100644 (file)
@@ -493,6 +493,7 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
                /* restore previous schema */
                if (cur_schema ) {
                        dsdb_reference_schema(ldb, cur_schema, false);
+                       dsdb_make_schema_global(ldb, cur_schema);
                }
 
                DEBUG(0,("Failed to apply records: %s: %s\n",
@@ -507,6 +508,7 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
                /* restore previous schema */
                if (cur_schema ) {
                        dsdb_reference_schema(ldb, cur_schema, false);
+                       dsdb_make_schema_global(ldb, cur_schema);
                }
                DEBUG(0,(__location__ " Failed to prepare commit of transaction: %s\n",
                         ldb_errstring(ldb)));
@@ -518,6 +520,7 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
                /* restore previous schema */
                if (cur_schema ) {
                        dsdb_reference_schema(ldb, cur_schema, false);
+                       dsdb_make_schema_global(ldb, cur_schema);
                }
                DEBUG(0,(__location__ " Failed to load partition uSN\n"));
                ldb_transaction_cancel(ldb);
@@ -536,6 +539,7 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
                /* restore previous schema */
                if (cur_schema ) {
                        dsdb_reference_schema(ldb, cur_schema, false);
+                       dsdb_make_schema_global(ldb, cur_schema);
                }
                DEBUG(0,(__location__ " Failed to commit transaction\n"));
                return WERR_FOOBAR;
@@ -549,6 +553,9 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
                cur_schema = dsdb_get_schema(ldb, NULL);
                /* TODO: What we do in case dsdb_get_schema() fail?
                 *       We can't fallback at this point anymore */
+               if (cur_schema) {
+                       dsdb_make_schema_global(ldb, cur_schema);
+               }
        }
 
        DEBUG(2,("Replicated %u objects (%u linked attributes) for %s\n",