|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
This page lists the runtime errors developers see most often when working with database_system, with concrete fixes. If your problem is not listed here, see Frequently Asked Questions or open an issue at https://github.com/kcenon/database_system/issues.
The driver could not reach the database host or the credentials were rejected. Check, in order:
pg_isready -h localhost, systemctl status mysql, mongo –eval "db.runCommand('ping')".psql, mysql, mongosh).set_mode() returns false if the backend was not built. Re-run CMake with -DUSE_POSTGRESQL=ON or the equivalent flag for your backend.sslmode=require to the connection string.A firewall is silently dropping the SYN packet, or the host name resolves to an unreachable address. Set an explicit timeout in the connection string (connect_timeout=5 for libpqxx, connectTimeoutMS=5000 for mongo-cxx-driver) so failures surface quickly, and verify the route with nc -vz host port.
Two transactions are waiting on each other's locks. The fix is one or more of:
users before orders, transaction B must do the same.BEGIN / COMMIT, and avoid user-input prompts inside a transaction.result.error() reports a serialization or deadlock code.SERIALIZABLE to READ COMMITTED if your invariants allow it.SQLite serialises writers. The error means another connection holds the write lock when yours tried to upgrade. Mitigations:
PRAGMA journal_mode=WAL to allow readers while a writer is active.BEGIN IMMEDIATE instead of plain BEGIN to acquire the write lock at transaction start.database_manager.The static metadata_ instance was never populated. Causes and fixes:
add_field**. Every ENTITY_FIELD has a matching <name>metadata member that must be added inside initialize_metadata()."static @c inline @c entity_metadata @c metadata_{...}" member with a unique table name.initialize_metadata() never ran. Make sure you used the ENTITY_METADATA() macro inside the class — it wires up the static initializer that calls initialize_metadata().A field marked not_null was left unset, or its value defaulted to null because the entity was constructed without assignment. Always assign every required field before calling save/insert, and consider adding a static factory that takes mandatory fields as constructor arguments.
Run the backend's EXPLAIN tool to see the execution plan. Common fixes:
field_constraint::index to the entity field used in the WHERE clause and re-run create_indexes_sql().BIGINT column against a string literal forces a sequential scan. Use the typed query builder values (int64_t{...}) so the dialect formats them correctly.SELECT * with an explicit projection. The query builder makes this trivial.select_query_result inside a loop, rewrite the work as a single JOIN or IN query.You are likely contending on the driver-level pool. Increase max_connections / maximumPoolSize on the driver, distribute the load across more database_manager instances, or move the workload behind the proxy mode (when available).
Use monitoring_system metrics from database/monitoring/performance_monitor.h to confirm where time is being spent.
Your migration script and the live schema are out of sync. To recover:
"\\d @c users" in psql, DESCRIBE users in MySQL, db.users.findOne() in mongosh).entity::get_metadata().create_table_sql(), prefer CREATE TABLE IF NOT EXISTS so the script remains idempotent.The DDL is using a dialect-specific feature. Examples:
JSONB exists only in PostgreSQL.SERIAL is PostgreSQL-only; use BIGSERIAL or per-backend auto-increment."CREATE @c INDEX @c IF @c NOT @c EXISTS" is supported by SQLite and PostgreSQL but not by older MySQL versions.When you want a single script to run everywhere, drive the schema from the ORM (create_table_sql) so the dialect translation happens centrally, or keep separate per-backend migration files.
result.error() output, and your CMake flags.