panicked at surrealdb/kvs-rocksdb/src/owned_tx.rs
Author: johansmitsnlCreated Sep 30, 2026Updated Sep 30, 2026
Labelstriagetopic:stability
What component does this affect?
SurrealDB Server
Describe the bug
Performing an update it crashes the server completely.
Sep 30 14:05:53 db surreal[1774558]: thread 'surrealdb-worker' (1774566) panicked at surrealdb/kvs-rocksdb/src/owned_tx.rs:217:13:
Sep 30 14:05:53 db surreal[1774558]: Cursor alive while trying to rollback transactionSteps to reproduce
- Create database (see seed data)
- Run query (see query)
-- SEED DATA
-- Synthetic legacy tenant data. Run only in a disposable SurrealDB 3.3.0 database.
DEFINE NAMESPACE repro;
DEFINE DATABASE repro;
DEFINE TABLE chat_conversation SCHEMALESS;
DEFINE TABLE dashboard_contribution SCHEMALESS;
DEFINE TABLE dashboard_total SCHEMALESS;
DEFINE TABLE script_migration SCHEMALESS;
FOR $number IN [1, 2, 3, 4, 5, 6] {
CREATE type::record('chat_conversation', string::concat('legacy_', <string>$number)) CONTENT {
title: string::concat('Synthetic conversation ', <string>$number),
created_at: time::now()
};
};
-- A conversation update refreshes its derived dashboard row in the same transaction.
-- The refresh reads the source table while the outer UPDATE cursor is active.
DEFINE FUNCTION fn::dashboard_refresh($source: record) {
LET $key = type::record('dashboard_contribution', crypto::sha256(<string>$source));
LET $row = SELECT * FROM ONLY $source;
LET $previous = SELECT * FROM ONLY $key;
UPSERT $key SET source = $source, kind = 'chats', site = $row.site,
occurred_at = $row.created_at, amount = 0dec, discount = 0dec;
};
DEFINE EVENT dashboard_totals ON dashboard_contribution
WHEN $event IN ['CREATE','UPDATE','DELETE'] THEN {
IF $event != 'CREATE' {
UPDATE dashboard_total:chats SET count -= 1, amount -= $before.amount;
};
IF $event != 'DELETE' {
UPSERT dashboard_total:chats SET count = (count ?? 0) + 1,
amount = (amount ?? 0dec) + $after.amount;
};
};
DEFINE EVENT dashboard_chat_conversation ON chat_conversation
WHEN $event = 'UPDATE' THEN {
fn::dashboard_refresh($after.id);
};--- query
-- Original failing migration shape: a bulk UPDATE fires an event that rereads
-- chat_conversation and writes dashboard_contribution for each legacy record.
BEGIN TRANSACTION;
LET $exists = SELECT VALUE id FROM script_migration
WHERE script_name = 'ProductEmployeeRoleScope';
IF array::len($exists) = 0 {
INSERT INTO script_migration {script_name: 'ProductEmployeeRoleScope'};
UPDATE chat_conversation SET staff_scope = {all:true,roles:[]}
WHERE staff_scope = NONE;
};
COMMIT TRANSACTION;Expected behaviour
To update the database with the query. This worked in 2.6.x
SurrealDB version
3.3.0 for linux on x86_64
Contact Details
Could this be a bug with your application?
- I confirm this is a bug with SurrealDB, not with my own application
Is there an existing issue for this?
- I confirm that I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: surrealdb/surrealdb