Transaction
Manage database transaction boundaries with atomic commit and rollback operations for data consistency.
Transaction
Control database transaction boundaries to ensure atomic operations and data consistency across multiple database operations. Used for maintaining data integrity in workflows involving multiple database modifications.
Quick Navigation
Transaction Control
Learn commit and rollback operations for atomic transactions
Usage Patterns
Discover common transaction patterns and error handling strategies
Integration Examples
See complete workflows with transactional safety
Best Practices
Error handling, rollback strategies, and performance considerations
Configuration
Inputs
| Name | Code | Type | Required | Description |
|---|---|---|---|---|
| Is Rollback | isRollback | Boolean | No | Whether to rollback the transaction (default: false) |
| Transaction ID | txId | Text | Conditional | Transaction identifier for specific transaction control |
💡 Transaction Scope
Transactions automatically span across all database operations within a workflow execution unless explicitly committed or rolled back.
Outputs
| Name | Type | Description |
|---|---|---|
| state | Text | Transaction result: "ok", "error", or "skipped" |
Transaction Control
Available Operations
| Operation | Purpose | Use Case | Safety Level |
|---|---|---|---|
| Commit | Permanently save changes | Complete successful operations | ✅ Safe |
| Rollback | Revert all changes | Handle errors and inconsistencies | 🔄 Recovery |
| Auto-commit | Default behavior | Simple single-operation workflows | ⚠️ Limited |
Transaction Lifecycle
Transaction Patterns
Integration Examples
Complete Transactional Workflows
Integration Pattern
Transactions work with database operations and external system integrations requiring atomicity.
Transaction States & Error Handling
State Management
| State | Description | Next Actions |
|---|---|---|
| ok | Transaction completed successfully | Continue workflow |
| error | Transaction operation failed | Handle error, retry if appropriate |
| skipped | No active transaction found | Check transaction scope |
Error Handling Patterns
Best Practices
Best Practices
- Keep transactions short to minimize lock contention
- Validate data early before starting expensive operations
- Use explicit rollbacks for complex error scenarios
- Monitor transaction scope to ensure proper boundaries
- Implement retry logic for transient failures
- Log transaction decisions for audit and debugging
Performance Considerations
⚠️ Performance Notes
- Long transactions can cause database locks and performance issues
- Nested transactions are not supported - use single transaction scope
- Concurrent workflows may experience lock contention on shared resources
- Large batch operations should be chunked to avoid timeout issues
Security Guidelines
| Security Aspect | Recommendation | Implementation |
|---|---|---|
| Transaction Isolation | Use appropriate isolation levels | Configure at database level |
| Audit Logging | Log all transaction decisions | Include user context and timestamps |
| Error Disclosure | Limit error information exposure | Use generic error messages in API responses |
| Permission Checking | Validate permissions before transactions | Check ctx.user.roles before database operations |
Common Anti-Patterns
Anti-Patterns
- Long-running transactions spanning user interactions
- Transactions without error handling leading to inconsistent state
- Ignoring transaction state in subsequent workflow logic
- Manual transaction management when auto-commit would suffice
- File operations within database transactions without proper cleanup
Troubleshooting
Common Issues
| Problem | Symptoms | Solution |
|---|---|---|
| Transaction state 'skipped' | No active transaction to commit | Verify database operations are within transaction scope |
| Deadlock errors | Concurrent transactions fail | Implement retry logic with exponential backoff |
| Partial rollback | Some changes persist after rollback | Check transaction boundaries and nested operation scope |
| Performance degradation | Slow database operations | Reduce transaction scope and duration |
Related Nodes
File Storage
Coordinate file operations with database transactions
Data Converter
Process data before transactional storage operations
Database Operations
Execute SQL commands within transaction scope
Next: Explore File Storage for coordinating file operations with transactions, or learn about Data Converter for processing data before storage operations.