Skip to content

Added Fixes for _PushStatus _SCHEMA Insertion and Ensuring Order for _PushStatus Row Update #2375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Controllers/PushController.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,18 @@ export class PushController extends AdaptableController {
if (!response.results) {
return Promise.reject({error: 'PushController: no results in query'})
}
pushStatus.setRunning(response.results);

/*
* The following code change ensures the correct order of the update of a particular _PushStatus row
* (first from 'pending' to 'running' and only then from 'running' to 'succeeded').
* Without this change, the order is not predictable always and cann lead to 'Object not found' error
* while updating the _PushStatus row.
*/
let runningPromise = pushStatus.setRunning(response.results);
return runningPromise.then(() => {
return response;
});
}).then((response) => {
return this.sendToAdapter(body, response.results, pushStatus, config);
}).then((results) => {
return pushStatus.complete(results);
Expand Down
14 changes: 14 additions & 0 deletions src/Controllers/SchemaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ class SchemaController {
return this.reloadDataPromise;
}
this.data = {};

/*
* This block of code ensures that the schema for volatile classes is always available
* and should never be created in _SCHEMA. Without this change, the invocation in DatabaseController
* causes the _PushStatus document to be added to _SCHEMA.
*/
volatileClasses.forEach(className => {
this.data[className] = injectDefaultSchema({
className,
fields: {},
classLevelPermissions: {}
});
});

this.perms = {};
this.reloadDataPromise = this.getAllClasses(options)
.then(allSchemas => {
Expand Down