-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Notes on NDB Datastore Transactions
A transaction is an operation or set of operations that is atomic -- either all of the operations in the transaction occur, or none of them occur. An application can perform multiple operations and calculations in a single transaction.
In the Oppia codebase, you can find transactions used in several places. Some examples are updating exploration statistics and user ratings, sending emails, and in MapReduce jobs.
When a function needs to be run as a transaction, use the annotation @transaction_services.run_in_transaction_wrapper
above the function.
Search for this annotation in the codebase for more examples.
The maximum number of models that can be operated on is limited to 25, so for example you can put_multi at max 25 models in one NDB datastore transaction (see source). If you need to operate on more than 25 models, look into core/domain/wipeout_service.py. In general, always write code to be rerunnable so that if one run fails, the subsequent run can take over and complete the task.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- FAQs
- How to get help
- Getting started with the project
- How the codebase is organized
- Making your first PR
- Debugging
- Testing
- Codebase policies and processes
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Testing jobs and other features on production
- Guidelines for Developers with Write Access to oppia/oppia
- Release schedule and other information
- Revert and Regression Policy
- Privacy aware programming
- Code review:
- Project organization:
- QA Testing:
- Design docs:
- Team-Specific Guides
- LaCE/CD:
- Developer Workflow:
Developer Reference
- Oppiabot
- Git cheat sheet
- Frontend
- Backend
- Backend Type Annotations
- Writing state migrations
- Calculating statistics
- Storage models
- Coding for speed in GAE
- Adding a new page
- Adding static assets
- Wipeout Implementation
- Notes on NDB Datastore transactions
- How to handle merging of change lists for exploration properties
- Instructions for editing roles or actions
- Protocol buffers
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Performance testing
- Build process
- Best practices for leading Oppia teams
- Past Events