Remove code related to db Upgrade callback.
MultiPart: 5/5
Change-Id: Ic4e24aaa0c2edf273549f784c1afcb6afa57bc96
diff --git a/src/gen-vdl/v.io/v23/security/access/index.js b/src/gen-vdl/v.io/v23/security/access/index.js
index a929339..043312e 100644
--- a/src/gen-vdl/v.io/v23/security/access/index.js
+++ b/src/gen-vdl/v.io/v23/security/access/index.js
@@ -13,6 +13,7 @@
var security = require('./..');
+var uniqueid = require('./../../uniqueid');
module.exports = {};
@@ -22,6 +23,7 @@
var _type1 = new vdl.Type();
var _type2 = new vdl.Type();
var _type3 = new vdl.Type();
+var _type4 = new vdl.Type();
var _typeAccessList = new vdl.Type();
var _typePermissions = new vdl.Type();
var _typeTag = new vdl.Type();
@@ -33,7 +35,10 @@
_type2.elem = vdl.types.STRING;
_type3.kind = vdl.kind.LIST;
_type3.name = "";
-_type3.elem = new security.RejectedBlessing()._type;
+_type3.elem = _typeTag;
+_type4.kind = vdl.kind.LIST;
+_type4.name = "";
+_type4.elem = new security.RejectedBlessing()._type;
_typeAccessList.kind = vdl.kind.STRUCT;
_typeAccessList.name = "v.io/v23/security/access.AccessList";
_typeAccessList.fields = [{name: "In", type: _type1}, {name: "NotIn", type: _type2}];
@@ -46,6 +51,7 @@
_type1.freeze();
_type2.freeze();
_type3.freeze();
+_type4.freeze();
_typeAccessList.freeze();
_typePermissions.freeze();
_typeTag.freeze();
@@ -68,6 +74,28 @@
module.exports.Resolve = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeTag))("Resolve", true), _typeTag);
+ module.exports.AccessTagCaveat = canonicalize.reduce(new security.CaveatDescriptor({
+ 'id': new Uint8Array([
+239,
+205,
+227,
+117,
+20,
+22,
+199,
+59,
+24,
+156,
+232,
+156,
+204,
+147,
+128,
+0,
+]),
+ 'paramType': _type3,
+}, true), new security.CaveatDescriptor()._type);
+
// Errors:
@@ -82,7 +110,7 @@
'en': '{1:}{2:} {3} does not have {5} access (rejected blessings: {4})',
}, [
_type2,
- _type3,
+ _type4,
vdl.types.STRING,
]);
@@ -91,7 +119,7 @@
'en': '{1:}{2:} {3} does not match the access list (rejected blessings: {4})',
}, [
_type2,
- _type3,
+ _type4,
]);
@@ -108,6 +136,14 @@
]);
+module.exports.AccessTagCaveatValidationError = makeError('v.io/v23/security/access.AccessTagCaveatValidation', actions.NO_RETRY, {
+ 'en': '{1:}{2:} access tags on method ({3}) do not include any of the ones in the caveat ({4}), or the method is using a different tag type',
+}, [
+ _type2,
+ _type3,
+]);
+
+
// Services:
diff --git a/src/gen-vdl/v.io/v23/services/syncbase/index.js b/src/gen-vdl/v.io/v23/services/syncbase/index.js
index dded181..35cf1a0 100644
--- a/src/gen-vdl/v.io/v23/services/syncbase/index.js
+++ b/src/gen-vdl/v.io/v23/services/syncbase/index.js
@@ -21,12 +21,12 @@
// Types:
-var _typeDebugUpdateClockOpts = new vdl.Type();
-_typeDebugUpdateClockOpts.kind = vdl.kind.STRUCT;
-_typeDebugUpdateClockOpts.name = "v.io/v23/services/syncbase.DebugUpdateClockOpts";
-_typeDebugUpdateClockOpts.fields = [{name: "NtpHost", type: vdl.types.STRING}, {name: "Now", type: new time.Time()._type}, {name: "ElapsedTime", type: new time.Duration()._type}, {name: "DoNtpUpdate", type: vdl.types.BOOL}, {name: "DoLocalUpdate", type: vdl.types.BOOL}, {name: "StartClockD", type: vdl.types.BOOL}];
-_typeDebugUpdateClockOpts.freeze();
-module.exports.DebugUpdateClockOpts = (vdl.registry.lookupOrCreateConstructor(_typeDebugUpdateClockOpts));
+var _typeDevModeUpdateVClockOpts = new vdl.Type();
+_typeDevModeUpdateVClockOpts.kind = vdl.kind.STRUCT;
+_typeDevModeUpdateVClockOpts.name = "v.io/v23/services/syncbase.DevModeUpdateVClockOpts";
+_typeDevModeUpdateVClockOpts.fields = [{name: "NtpHost", type: vdl.types.STRING}, {name: "Now", type: new time.Time()._type}, {name: "ElapsedTime", type: new time.Duration()._type}, {name: "DoNtpUpdate", type: vdl.types.BOOL}, {name: "DoLocalUpdate", type: vdl.types.BOOL}];
+_typeDevModeUpdateVClockOpts.freeze();
+module.exports.DevModeUpdateVClockOpts = (vdl.registry.lookupOrCreateConstructor(_typeDevModeUpdateVClockOpts));
@@ -37,6 +37,12 @@
// Errors:
+module.exports.NotInDevModeError = makeError('v.io/v23/services/syncbase.NotInDevMode', actions.NO_RETRY, {
+ 'en': '{1:}{2:} not running with --dev=true',
+}, [
+]);
+
+
module.exports.InvalidNameError = makeError('v.io/v23/services/syncbase.InvalidName', actions.NO_RETRY, {
'en': '{1:}{2:} invalid name: {3}',
}, [
@@ -44,6 +50,19 @@
]);
+module.exports.CorruptDatabaseError = makeError('v.io/v23/services/syncbase.CorruptDatabase', actions.NO_RETRY, {
+ 'en': '{1:}{2:} database corrupt, moved to {3}; client must create a new database',
+}, [
+ vdl.types.STRING,
+]);
+
+
+module.exports.UnknownBatchError = makeError('v.io/v23/services/syncbase.UnknownBatch', actions.NO_RETRY, {
+ 'en': '{1:}{2:} unknown batch, perhaps the server restarted',
+}, [
+]);
+
+
// Services:
@@ -55,13 +74,13 @@
-Service.prototype.debugUpdateClock = function(ctx, serverCall, uco) {
- throw new Error('Method DebugUpdateClock not implemented');
+Service.prototype.devModeUpdateVClock = function(ctx, serverCall, uco) {
+ throw new Error('Method DevModeUpdateVClock not implemented');
};
-Service.prototype.debugNow = function(ctx, serverCall) {
- throw new Error('Method DebugNow not implemented');
+Service.prototype.devModeGetTime = function(ctx, serverCall) {
+ throw new Error('Method DevModeGetTime not implemented');
};
@@ -90,12 +109,12 @@
{
- name: 'DebugUpdateClock',
- doc: "// DebugUpdateClock updates various bits of Syncbase virtual clock and clock\n// daemon state based on the specified options.\n// Requires --debug flag to be set (in addition to Admin check).\n// Users of this function typically specify --debug-do-not-start-clockd when\n// starting Syncbase so that they can configure the virtual clock before the\n// daemon starts mucking with it.",
+ name: 'DevModeUpdateVClock',
+ doc: "// DevModeUpdateVClock updates various bits of Syncbase virtual clock and clock\n// daemon state based on the specified options.\n// Requires --dev flag to be set (in addition to Admin check).",
inArgs: [{
name: 'uco',
doc: "",
- type: _typeDebugUpdateClockOpts
+ type: _typeDevModeUpdateVClockOpts
},
],
outArgs: [],
@@ -106,8 +125,8 @@
{
- name: 'DebugNow',
- doc: "// DebugNow returns the current time per the Syncbase clock.\n// Requires --debug flag to be set (in addition to Admin check).",
+ name: 'DevModeGetTime',
+ doc: "// DevModeGetTime returns the current time per the Syncbase clock.\n// Requires --dev flag to be set (in addition to Admin check).",
inArgs: [],
outArgs: [{
name: '',
diff --git a/src/gen-vdl/v.io/v23/services/syncbase/nosql/index.js b/src/gen-vdl/v.io/v23/services/syncbase/nosql/index.js
index 9fab3d3..91dc09c 100644
--- a/src/gen-vdl/v.io/v23/services/syncbase/nosql/index.js
+++ b/src/gen-vdl/v.io/v23/services/syncbase/nosql/index.js
@@ -12,6 +12,7 @@
+var time = require('./../../../vdlroot/time');
var access = require('./../../../security/access');
var permissions = require('./../../permissions');
var watch = require('./../../watch');
@@ -56,6 +57,7 @@
var _typeTableRow = new vdl.Type();
var _typeValue = new vdl.Type();
var _typeValueSelection = new vdl.Type();
+var _typeValueState = new vdl.Type();
_type1.kind = vdl.kind.LIST;
_type1.name = "";
_type1.elem = vdl.types.STRING;
@@ -157,10 +159,13 @@
_typeTableRow.fields = [{name: "TableName", type: vdl.types.STRING}, {name: "Row", type: vdl.types.STRING}];
_typeValue.kind = vdl.kind.STRUCT;
_typeValue.name = "v.io/v23/services/syncbase/nosql.Value";
-_typeValue.fields = [{name: "Bytes", type: _type4}, {name: "WriteTs", type: vdl.types.INT64}];
+_typeValue.fields = [{name: "State", type: _typeValueState}, {name: "Bytes", type: _type4}, {name: "WriteTs", type: new time.Time()._type}];
_typeValueSelection.kind = vdl.kind.ENUM;
_typeValueSelection.name = "v.io/v23/services/syncbase/nosql.ValueSelection";
_typeValueSelection.labels = ["Local", "Remote", "Other"];
+_typeValueState.kind = vdl.kind.ENUM;
+_typeValueState.name = "v.io/v23/services/syncbase/nosql.ValueState";
+_typeValueState.labels = ["Exists", "NoExists", "Deleted", "Unknown"];
_type1.freeze();
_type10.freeze();
_type2.freeze();
@@ -196,6 +201,7 @@
_typeTableRow.freeze();
_typeValue.freeze();
_typeValueSelection.freeze();
+_typeValueState.freeze();
module.exports.BatchInfo = (vdl.registry.lookupOrCreateConstructor(_typeBatchInfo));
module.exports.BatchOptions = (vdl.registry.lookupOrCreateConstructor(_typeBatchOptions));
module.exports.BatchSource = {
@@ -237,6 +243,12 @@
REMOTE: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeValueSelection))('Remote', true), _typeValueSelection),
OTHER: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeValueSelection))('Other', true), _typeValueSelection),
};
+module.exports.ValueState = {
+ EXISTS: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeValueState))('Exists', true), _typeValueState),
+ NO_EXISTS: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeValueState))('NoExists', true), _typeValueState),
+ DELETED: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeValueState))('Deleted', true), _typeValueState),
+ UNKNOWN: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeValueState))('Unknown', true), _typeValueState),
+};
@@ -285,6 +297,12 @@
]);
+module.exports.SyncgroupJoinFailedError = makeError('v.io/v23/services/syncbase/nosql.SyncgroupJoinFailed', actions.NO_RETRY, {
+ 'en': '{1:}{2:} syncgroup join failed',
+}, [
+]);
+
+
// Services:
@@ -1269,7 +1287,7 @@
{
name: 'Exec',
- doc: "// Exec executes a syncQL query and returns all results as specified by in the\n// query's select clause. Concurrency semantics are documented in model.go.",
+ doc: "// Exec executes a syncQL query and returns all results as specified by in the\n// query's select/delete statement. Concurrency semantics are documented in model.go.",
inArgs: [{
name: 'schemaVersion',
doc: "",
@@ -1294,7 +1312,7 @@
{
name: 'BeginBatch',
- doc: "// BeginBatch creates a new batch. It returns a \"batch suffix\" string to\n// append to the object name of this Database, yielding an object name for the\n// Database bound to the created batch. (For example, if this Database is\n// named \"/path/to/db\" and BeginBatch returns \"##abc\", the client should\n// construct batch Database object name \"/path/to/db##abc\".) If this Database\n// is already bound to a batch, BeginBatch() will fail with ErrBoundToBatch.\n// Concurrency semantics are documented in model.go.\n// TODO(sadovsky): Maybe make BatchOptions optional.",
+ doc: "// BeginBatch creates a new batch. It returns a \"batch suffix\" string to\n// append to the object name of this Database, yielding an object name for the\n// Database bound to the created batch. (For example, if this Database is\n// named \"/path/to/db\" and BeginBatch returns \"##abc\", the client should\n// construct batch Database object name \"/path/to/db##abc\".) If this Database\n// is already bound to a batch, BeginBatch() will fail with ErrBoundToBatch.\n// Concurrency semantics are documented in model.go.\n// TODO(sadovsky): Maybe make BatchOptions optional. Also, rename it to 'opts'\n// everywhere now that v.io/i/912 is resolved.",
inArgs: [{
name: 'schemaVersion',
doc: "",
diff --git a/src/nosql/database.js b/src/nosql/database.js
index 0a8cd7b..8558f12 100644
--- a/src/nosql/database.js
+++ b/src/nosql/database.js
@@ -223,23 +223,15 @@
/**
* Compares the current schema version of the database with the schema version
- * provided while creating this database handle. If the current database schema
- * version is lower, then schema.updater is called. If schema.updater is
- * successful this method stores the new schema metadata in database.
+ * provided while creating this database handle and updates the schema metadata
+ * if required.
*
- * It is important not to access or modify the database until upgradeIfOutdated
- * has called its callback.
- *
- * TODO(nlacasse): Consider locking the database in some way so that the
- * upgrader function can access it, but all other attempts fail immediately
- * with a helpful error.
- *
- * Note: schema can be nil, in which case this method skips schema check and
+ * Note: schema can be nil, in which case this method should not be called and
* the caller is responsible for maintaining schema sanity.
* @param {module:vanadium.context.Context} ctx Vanadium context.
* @param {function} cb Callback.
*/
-Database.prototype.upgradeIfOutdated = function(ctx, cb) {
+Database.prototype.updateSchemaMetadata = function(ctx, cb) {
var self = this;
if (!self.schema) {
return process.nextTick(function() {
@@ -283,26 +275,12 @@
return cb(null, false);
}
- // Call the Upgrader provided by the app to upgrade the schema.
- //
- // TODO(nlacasse,jlodhia): disable sync before running Upgrader and
- // reenable once Upgrader is finished.
- //
- // TODO(nlacasse,jlodhia): prevent other processes (local/remote) from
- // accessing the database while upgrade is in progress.
- self.schema.upgrader(self, currMeta.version, self.schema.metadata.version,
- function(err) {
+ // Update the schema metadata in db to the latest version.
+ self._setSchemaMetadata(ctx, self.schema.metadata, function(err) {
if (err) {
return cb(err);
}
-
- // Update the schema metadata in db to the latest version.
- self._setSchemaMetadata(ctx, self.schema.metadata, function(err) {
- if (err) {
- return cb(err);
- }
- cb(null, true);
- });
+ cb(null, true);
});
});
};
diff --git a/src/nosql/schema.js b/src/nosql/schema.js
index b98f77a..29ce649 100644
--- a/src/nosql/schema.js
+++ b/src/nosql/schema.js
@@ -8,36 +8,20 @@
* Each database has a Schema associated with it which defines the current
* version of the database. When a new version of app wishes to change its data
* in a way that it is not compatible with the old app's data, the app must
- * change the schema version and provide relevant upgrade logic in the
- * Upgrader. The conflict resolution rules are also associated with the schema
+ * change the schema version and perform relevant upgrade logic.
+ * The conflict resolution rules are also associated with the schema
* version. Hence if the conflict resolution rules change then the schema
* version also must be bumped.
*
- * Schema provides metadata and an upgrader for a given database.
+ * Schema provides metadata for a given database.
*
* @constructor
* @param {module:syncbase.nosql.SchemaMetadata} metadata Schema metadata.
- * @param {module:syncbase.nosql.Schema~upgrader} upgrader Upgrader function.
*/
-function Schema(metadata, upgrader) {
+function Schema(metadata) {
Object.defineProperty(this, 'metadata', {
value: metadata,
writable: false,
enumerable: false
});
-
- Object.defineProperty(this, 'upgrader', {
- value: upgrader,
- writable: false,
- enumerable: false
- });
}
-
-/**
- * Schema upgrader function.
- * @callback module:syncbase.Schema~upgrader
- * @param {module:syncbase.nosql.Database} db Database.
- * @param {num} oldVersion Old version.
- * @param {num} newVersion New version.
- * @param {function} cb Callback to call when done.
- */
diff --git a/test/integration/test-database.js b/test/integration/test-database.js
index 262d453..d69910c 100644
--- a/test/integration/test-database.js
+++ b/test/integration/test-database.js
@@ -61,8 +61,7 @@
var version = 123;
var md = new SchemaMetadata({version: version});
- var updater = function() {};
- var schema = new Schema(md, updater);
+ var schema = new Schema(md);
var dbName = uniqueName('db');
var db = o.app.noSqlDatabase(dbName, schema);
diff --git a/test/integration/test-schema.js b/test/integration/test-schema.js
index 299777c..b4d4472 100644
--- a/test/integration/test-schema.js
+++ b/test/integration/test-schema.js
@@ -24,30 +24,20 @@
var dbName = uniqueName('db');
- var upgraderCallCount = 0;
- var upgrader = function(db, oldVer, newVer, cb) {
- upgraderCallCount++;
- process.nextTick(function() {
- cb(null);
- });
- };
-
var version = 123;
var md = new SchemaMetadata({version: version});
- var schema = new Schema(md, upgrader);
+ var schema = new Schema(md);
var otherDb, otherSchema, newVersion;
var db = app.noSqlDatabase(dbName, schema);
async.waterfall([
- // Verify that calling Upgrade on a non existing database does not throw
- // errors.
- db.upgradeIfOutdated.bind(db, ctx),
+ // Verify that calling updateSchemaMetadata on a non existing database
+ // does not throw errors.
+ db.updateSchemaMetadata.bind(db, ctx),
function(upgraded, cb) {
- t.equal(upgraded, false, 'upgradeIfOutdated should return false');
- t.equal(upgraderCallCount, 0,
- 'upgrader function should not have been called');
+ t.equal(upgraded, false, 'updateSchemaMetadata should return false');
cb(null);
},
@@ -65,28 +55,18 @@
cb(null);
},
- // Make redundant call to Upgrade to verify that it is a no-op
- db.upgradeIfOutdated.bind(db, ctx),
- function(res, cb) {
- t.notOk(res, 'upgradeIfOutdated should not return true');
- t.equal(upgraderCallCount, 0,
- 'upgrader function should not have been called');
- cb(null);
- },
-
// Try to make a new database object for the same database but with an
// incremented schema version.
function(cb) {
newVersion = version + 1;
var otherMd = new SchemaMetadata({version: newVersion});
- otherSchema = new Schema(otherMd, upgrader);
+ otherSchema = new Schema(otherMd);
otherDb = app.noSqlDatabase(dbName, otherSchema);
- otherDb.upgradeIfOutdated(ctx, cb);
+ otherDb.updateSchemaMetadata(ctx, cb);
},
function(res, cb) {
- t.ok(res, 'otherDb.upgradeIfOutdated expected to return true');
- t.equal(upgraderCallCount, 1, 'upgrader should have been called once');
+ t.ok(res, 'otherDb.updateSchemaMetadata expected to return true');
cb(null);
},