UserManagementTransaction
Manages complex, multi-step operations in user management as atomic transactions, ensuring data consistency and enabling rollback capabilities. Many user operations involve multiple related changes - for example, user registration might create a user record, set up authentication, send verification emails, create default preferences, and assign initial roles. This entity wraps all these steps into a single transaction that either completely succeeds or completely fails, preventing partial states that could leave the system inconsistent. Each transaction records its type (registration, password change, account deletion), current state (pending, in progress, committed, rolled back), and all operations performed. The checkpoint data allows the system to rollback changes if something fails midway through. This is particularly important for operations that interact with external systems - if sending a welcome email fails, the entire registration can be rolled back. The entity supports different isolation levels for concurrent operations and includes retry logic for transient failures. It provides an audit trail of complex operations and helps diagnose issues when multi-step processes fail. This transactional approach is essential for maintaining data integrity in distributed systems where operations might span multiple services or databases.
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| transactionId | uuid | stored | Unique identifier for this transaction | Required |
| transactionType | string | enum | Category of operation being performed Values: | Required |
| state | string | enum | Current status of the transaction Values: | Required |
| isolationLevel | string | enum | Database isolation level for concurrent operations Values: | Optional |
| initiator | User | stored | User who initiated this transaction | Optional |
| affectedUserId | uuid | stored | Primary user affected by this transaction | Required |
| affectedUserIds | string | stored | JSON array of all affected user IDs for bulk operations | Optional |
| operations | string | stored | JSON array of all operations in this transaction with their status Example: | Required |
| startedAt | DateTime | stored | When the transaction began | Required |
| committedAt | DateTime | stored | When all operations were successfully committed | Optional |
| rolledBackAt | DateTime | stored | When the transaction was rolled back | Optional |
| completedAt | DateTime | stored | When the transaction finished (success or failure) | Optional |
| errorMessage | string | stored | Error details if the transaction failed | Optional |
| errorStep | string | stored | Which operation step failed | Optional |
| checkpointData | string | stored | JSON snapshot of data before transaction for rollback | Optional |
| rollbackData | string | stored | Data needed to reverse the operations | Optional |
| retryCount | integer | stored | Number of retry attempts made | Optional |
| maxRetries | integer | stored | Maximum retries allowed for this transaction | Optional |
| metadata | string | stored | Additional context about the transaction | Optional |
| version | integer | stored | Version for optimistic locking | Optional |
Examples
Example 1
{
"@type": "UserManagementTransaction",
"transactionId": "txn_abc123",
"transactionType": "user_registration",
"state": "committed",
"isolationLevel": "read_committed",
"affectedUserId": "user_new_789",
"operations": "[{\"operation\":\"create_user\",\"status\":\"completed\",\"timestamp\":\"2024-03-15T10:00:00Z\"},{\"operation\":\"create_authentication\",\"status\":\"completed\",\"timestamp\":\"2024-03-15T10:00:01Z\"},{\"operation\":\"send_verification_email\",\"status\":\"completed\",\"timestamp\":\"2024-03-15T10:00:02Z\"},{\"operation\":\"assign_default_role\",\"status\":\"completed\",\"timestamp\":\"2024-03-15T10:00:03Z\"}]",
"startedAt": "2024-03-15T10:00:00Z",
"committedAt": "2024-03-15T10:00:03Z",
"completedAt": "2024-03-15T10:00:03Z",
"retryCount": 0,
"metadata": "{\"registration_source\":\"web\",\"ip_address\":\"192.168.1.100\"}",
"version": 2
}Example 2
{
"@type": "UserManagementTransaction",
"transactionId": "txn_failed_456",
"transactionType": "bulk_operation",
"state": "rolled_back",
"isolationLevel": "serializable",
"initiator": "admin_123",
"affectedUserId": "batch_operation",
"affectedUserIds": "[\"user_001\",\"user_002\",\"user_003\",\"user_004\",\"user_005\"]",
"operations": "[{\"operation\":\"update_role\",\"status\":\"completed\",\"users\":[\"user_001\",\"user_002\",\"user_003\"]},{\"operation\":\"update_permissions\",\"status\":\"failed\",\"error\":\"Permission not found\"}]",
"startedAt": "2024-03-15T14:00:00Z",
"rolledBackAt": "2024-03-15T14:00:05Z",
"completedAt": "2024-03-15T14:00:05Z",
"errorMessage": "Permission 'advanced_analytics' does not exist",
"errorStep": "update_permissions",
"checkpointData": "{\"original_roles\":{\"user_001\":\"basic\",\"user_002\":\"basic\",\"user_003\":\"premium\"}}",
"retryCount": 2,
"maxRetries": 3,
"version": 4
}