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.

20 properties
Schema

Properties

PropertyTypeModeDescriptionRequired
transactionIduuid
stored

Unique identifier for this transaction

Required
transactionTypestring
enum

Category of operation being performed

Values: user_registration, password_change, authentication, profile_update, 2fa_setup, api_key_creation, bulk_operation, account_deletion, role_assignment, permission_update

Required
statestring
enum

Current status of the transaction

Values: pending, in_progress, committed, rolled_back, failed, partially_committed

Required
isolationLevelstring
enum

Database isolation level for concurrent operations

Values: read_uncommitted, read_committed, repeatable_read, serializable

Optional
initiatorUser
stored

User who initiated this transaction

Optional
affectedUserIduuid
stored

Primary user affected by this transaction

Required
affectedUserIdsstring
stored

JSON array of all affected user IDs for bulk operations

Optional
operationsstring
stored

JSON array of all operations in this transaction with their status

Example: "[{\"operation\":\"create_user\",\"status\":\"completed\"},{\"operation\":\"send_email\",\"status\":\"pending\"}]"

Required
startedAtDateTime
stored

When the transaction began

Required
committedAtDateTime
stored

When all operations were successfully committed

Optional
rolledBackAtDateTime
stored

When the transaction was rolled back

Optional
completedAtDateTime
stored

When the transaction finished (success or failure)

Optional
errorMessagestring
stored

Error details if the transaction failed

Optional
errorStepstring
stored

Which operation step failed

Optional
checkpointDatastring
stored

JSON snapshot of data before transaction for rollback

Optional
rollbackDatastring
stored

Data needed to reverse the operations

Optional
retryCountinteger
stored

Number of retry attempts made

Optional
maxRetriesinteger
stored

Maximum retries allowed for this transaction

Optional
metadatastring
stored

Additional context about the transaction

Optional
versioninteger
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
}