Skip to content

Commit

Permalink
Only one configuration should exist per service
Browse files Browse the repository at this point in the history
Fixes #3514. Follow-up to pull request #3290.
  • Loading branch information
DanielDent authored and glasser committed Mar 6, 2015
1 parent 759510a commit 831bd3f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/service-configuration/package.js
Expand Up @@ -8,4 +8,5 @@ Package.onUse(function(api) {
api.use('mongo', ['client', 'server']);
api.export('ServiceConfiguration');
api.addFiles('service_configuration_common.js', ['client', 'server']);
api.addFiles('service_configuration_server.js', 'server');
});
30 changes: 30 additions & 0 deletions packages/service-configuration/service_configuration_server.js
@@ -0,0 +1,30 @@
// Only one configuration should ever exist for each service.
// A unique index helps avoid various race conditions which could
// otherwise lead to an inconsistent database state (when there are multiple
// configurations for a single service, which configuration is correct?)
try {
ServiceConfiguration.configurations._ensureIndex(
{ "service": 1 },
{ unique: true }
);
} catch (err) {
console.error(
"The service-configuration package persists configuration in the " +
"meteor_accounts_loginServiceConfiguration collection in MongoDB. As " +
"each service should have exactly one configuration, Meteor " +
"automatically creates a MongoDB index with a unique constraint on the " +
" meteor_accounts_loginServiceConfiguration collection. The " +
"_ensureIndex command which creates that index is failing.\n\n" +
"Meteor versions <= 1.0.3.1 did not create this index. If you recently " +
"upgraded and are seeing this error message for the first time, please " +
"check your meteor_accounts_loginServiceConfiguration collection for " +
"multiple configuration entries for the same service and delete " +
"configuration entries until there is no more than one configuration " +
"entry per service.\n\n" +
"If the meteor_accounts_loginServiceConfiguration collection looks " +
"fine, the _ensureIndex command is failing for some other reason.\n\n" +
"For more information on this history of this issue, please see " +
"https://github.com/meteor/meteor/pull/3514.\n"
);
throw err;
}

0 comments on commit 831bd3f

Please sign in to comment.