Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

DBMS → Deadlock 16

What is edge chasing for distributed deadlock detection?
Nodes proactively push probe messages along wait-for edges toward the transaction being waited for; if a probe returns to its origin a cycle (deadlock) is detected; avoids the need for a centralized global wait-for graph
click to copy
What is deadlock avoidance vs deadlock prevention and which requires advance knowledge?
Deadlock prevention eliminates one of the Coffman conditions (no advance knowledge needed). Deadlock avoidance requires each transaction to declare maximum resource needs in advance; the system uses this to determine if granting a request could lead to deadlock and denies unsafe requests
click to copy
What is the deadlock frequency trade-off in choosing lock granularity?
Coarser granularity (table locks): fewer locks per transaction = fewer potential conflicts = fewer deadlocks but less concurrency. Finer granularity (row locks): more locks per transaction = more potential for circular wait = higher deadlock probability but higher concurrency
click to copy
How can application developers minimize the probability of deadlocks?
Best practices: (1) Acquire locks in consistent order across all transactions. (2) Keep transactions short (fewer locks held for less time). (3) Access data in same order. (4) Use appropriate isolation level. (5) Use SELECT FOR UPDATE to acquire all needed locks upfront. (6) Retry logic for deadlock errors
click to copy
What is the relationship between deadlocks and the two-phase locking protocol?
2PL guarantees serializability but does NOT prevent deadlocks; in fact 2PL can cause deadlocks because transactions hold locks during the shrinking phase while waiting for new locks - deadlock prevention or detection must be combined with 2PL separately
click to copy
What is a deadlock graph visualization and how does it help in diagnosing production deadlock issues?
A visual representation of transactions as nodes and lock wait relationships as directed edges; cycles indicate deadlocks; helps identify: which transactions are involved which specific rows/tables are the contention points what SQL statements caused conflicts and patterns suggesting application-level fixes
click to copy
In MySQL InnoDB when a deadlock is detected what information does InnoDB provide?
InnoDB has automatic deadlock detection using a wait-for graph; when detected the transaction with less undo log is chosen as victim and rolled back; deadlock information is accessible via SHOW ENGINE INNODB STATUS or the performance_schema.data_lock_waits table
click to copy
What is mutual exclusion as a Coffman condition and can it be eliminated in database systems to prevent deadlocks?
Mutual exclusion means resources (data items) can only be held by one transaction at a time in write mode; for READ locks mutual exclusion can be eliminated (multiple readers allowed) via shared locks reducing deadlock probability; but write locks inherently require mutual exclusion for correctness
click to copy
What is the application-level deadlock and how does it differ from database-level deadlock?
Application-level deadlock: occurs in application code (e.g. Thread A holds Java lock L1 waiting for Java lock L2; Thread B holds L2 waiting for L1) without involving database locks - the database itself is not deadlocked but the application threads are stuck. Different from DB deadlock where DBMS transactions hold DB locks circularly
click to copy
What is the Bankers algorithm for deadlock avoidance and what information does it require?
A resource allocation algorithm that determines whether granting a resource request leaves the system in a safe state; requires: for each transaction - maximum resource needs declared in advance current allocation and remaining need; safe state = exists a sequence in which all transactions can complete using available resources
click to copy
What is the hold-and-wait Coffman condition and what strategies eliminate it in database systems?
Hold-and-wait: a transaction holds one or more resources (locks) while waiting to acquire additional resources it needs. Elimination strategies: (1) Require all-or-nothing lock acquisition (acquire ALL needed locks at once before starting) (2) Release all current locks before requesting new ones (3) Use timeout-based retry after releasing
click to copy
What is the no-preemption Coffman condition and how can preemption be introduced to break deadlocks?
No preemption means that resources (locks) cannot be forcibly taken from a transaction holding them. Preemption can be introduced by: aborting (preempting) a deadlocked transaction (victim selection) which is how deadlock resolution works - the DBMS forcibly rolls back a chosen victim transaction releasing its locks for other waiting transactions
click to copy
What is the difference between deadlock detection frequency and deadlock detection latency?
Detection frequency: how often the deadlock detector runs (e.g. every 100ms or every N lock requests); Detection latency: how long a deadlock persists before being detected and resolved (= time to next detection run + detection + abort time). Trade-off: higher frequency = lower latency but higher CPU overhead from running detection; lower frequency = lower overhead but deadlocked transactions blocked longer
click to copy
What is cycle prevention vs cycle detection in the context of deadlock management strategies?
Cycle prevention: design the system so that cycles in the wait-for graph cannot form (e.g., lock ordering, Wait-Die, Wound-Wait, no-wait) - proactive approach that adds overhead to every transaction. Cycle detection: allow cycles to form then detect and break them periodically (e.g., wait-for graph cycle detection) - reactive approach lower per-transaction overhead but deadlocks persist briefly
click to copy
What is the innodb_deadlock_detect system variable in MySQL and what is the alternative when it is disabled?
innodb_deadlock_detect=ON (default): InnoDB actively detects deadlocks using a wait-for graph and immediately resolves them by aborting a victim. innodb_deadlock_detect=OFF: deadlock detection is disabled; the lock wait timeout (innodb_lock_wait_timeout) becomes the only mechanism to break deadlocks - transactions wait until timeout then abort. Disabling detection reduces overhead in very high-concurrency scenarios but increases worst-case deadlock resolution time.
click to copy
What are the implications of deadlocks in distributed microservices systems that use distributed transactions (SAGA pattern)?
In SAGA-based distributed transactions traditional database deadlocks at the local level can still occur within each services database; additionally SAGA introduces higher-level semantic deadlocks where multiple sagas wait for each other to complete compensating actions or where resource locks across services create circular dependencies - resolved by designing sagas to acquire resources in consistent order and implementing timeouts for saga steps
click to copy

DBMS → Database Security 24

What is role-based access control (RBAC) in database security?
RBAC: privileges are assigned to roles (logical groups) and roles are assigned to users; changing a roles privileges automatically affects all users with that role. Direct grants: privileges assigned directly to individual users making management complex and error-prone at scale
click to copy
What is row-level security (RLS) and how does it differ from view-based row filtering?
RLS is a database feature where security policies are automatically applied to queries at the database level based on the executing user/role transparently filtering rows without requiring application code or view modifications; views require explicit usage and can be bypassed if user has direct table access
click to copy
What is transparent data encryption (TDE) and what threat does it protect against?
Database-level encryption where data files log files and backups are encrypted on disk automatically by the DBMS without application changes; protects against: theft of physical storage media unauthorized access to database file copies but does NOT protect against authorized database users or SQL injection
click to copy
What is data masking (static vs dynamic) in database security?
Static data masking: permanently replaces sensitive data with realistic but fictitious values in non-production copies. Dynamic data masking: applies masking rules at query time for specific users returning masked values while original data remains stored unchanged
click to copy
What is discretionary access control (DAC) vs mandatory access control (MAC)?
DAC: resource owners control access permissions (GRANT/REVOKE by object owner) - flexible but owners can grant to anyone. MAC: system-enforced labels on data and users (e.g. TOP SECRET data accessible only by TOP SECRET cleared users) owner cannot override - used in government/defense systems
click to copy
What is database auditing and what are the key events that should be audited?
Recording and monitoring database activities for security analysis compliance and forensics; key events to audit: all DDL changes privilege grants/revokes failed login attempts access to sensitive tables (PII financial) privileged user actions and unusual query patterns
click to copy
What is least privilege principle applied to database security?
Application database accounts should have only the minimum privileges required for their specific function: SELECT only for read-only applications INSERT/UPDATE/DELETE on specific tables for write operations no DDL permissions no GRANT permissions no access to system tables or other schemas
click to copy
What is encryption at rest vs encryption in transit for database security?
Encryption at rest: protects data stored on disk (TDE filesystem encryption) from physical theft/unauthorized file access. Encryption in transit: protects data moving between client and database server (TLS/SSL) from network eavesdropping. Both needed because threat model has both physical and network vectors
click to copy
What is privilege escalation vulnerability in database security and how is it prevented?
A security vulnerability where an attacker gains higher privileges than intended e.g. through SQL injection granting admin access exploiting stored procedure definer rights or GRANT OPTION abuse. Prevented by: least privilege principle removing unnecessary privileges auditing privilege assignments
click to copy
What is column-level security in database access control and how is it implemented?
Restricting access to specific columns rather than entire tables; implementations: (1) View-based: create views that SELECT only permitted columns. (2) Column-level privileges: GRANT SELECT(col1 col2) ON table TO user. (3) Column-level encryption: columns encrypted with keys only authorized users possess
click to copy
What is inference attack in database security?
Combining multiple non-sensitive queries or pieces of information to deduce sensitive information that is not directly accessible; e.g. if a statistical query reveals the average salary of a 1-person department that reveals the single persons salary even if individual salary queries are blocked
click to copy
What is database tokenization and how does it differ from encryption?
Tokenization: replacing sensitive data (credit card numbers) with randomly generated tokens that have no mathematical relationship to the original data; tokens are stored in a secure token vault. Encryption: mathematically transforms data using a key (can be decrypted with key). Tokenization cannot be reversed without vault access
click to copy
What is differential privacy in the context of database query systems?
A mathematical framework that adds calibrated noise to query results providing a formal guarantee: the probability of learning any specific fact about an individual is nearly the same whether or not that individuals data is in the database (epsilon-differential privacy)
click to copy
What is k-anonymity in database privacy and what are its limitations?
A privacy model ensuring each record is indistinguishable from at least k-1 other records with respect to quasi-identifying attributes; limitations: vulnerable to homogeneity attacks (if all k records have same sensitive value) and background knowledge attacks
click to copy
What is the GRANT WITH GRANT OPTION privilege and why is it considered a security risk?
Allows the grantee to further grant the same privilege to other users; security risk: privilege can propagate uncontrollably (Alice grants to Bob WITH GRANT OPTION Bob grants to 100 other users without DBA knowledge) creating uncontrolled access expansion that is difficult to audit and revoke
click to copy
What is database activity monitoring (DAM) and how does it differ from native database auditing?
An independent security layer that monitors all database traffic in real-time without relying on native DBMS audit features; benefits over native auditing: cannot be disabled by DBAs (separation of duties) lower performance impact (passive network monitoring) cross-DBMS policy enforcement real-time alerting
click to copy
What is database vulnerability assessment and what categories of vulnerabilities does it check?
A systematic security assessment of database configurations and code identifying: misconfigured privileges (public grants excessive DBA accounts) weak authentication (default passwords weak policies) unpatched software (known CVEs) insecure configurations (remote root login unnecessary features enabled) SQL injection vulnerabilities in stored procedures
click to copy
What is REVOKE CASCADE behavior and why is it a security concern?
REVOKE privilege FROM user CASCADE: also revokes the privilege from all users who received it from that user via GRANT WITH GRANT OPTION (cascading revocation); security concern: unexpected cascade may revoke privileges from many users not intended for revocation
click to copy
What is database forensics and what information sources are used in post-incident investigation?
Post-incident analysis of database systems to reconstruct what happened: examining transaction logs (redo/undo) audit trails access logs network packet captures OS logs and potentially deleted/recovered data to determine the sequence of events identify the attacker and assess the scope of a breach
click to copy
What is the concept of database firewall and what does it do?
A security layer that sits between the application and the database server monitoring and filtering SQL statements in real-time based on whitelisted allowed query patterns blocking anomalous or malicious SQL - detects SQL injection unauthorized queries and policy violations
click to copy
What is the concept of data classification in database security and why is it important?
The process of categorizing data based on its sensitivity level (e.g. public internal confidential restricted/top-secret) so that appropriate security controls can be applied proportionally - critical because it determines access controls encryption requirements audit levels backup policies and regulatory compliance obligations
click to copy
What is the concept of database hardening and what does it include?
The process of reducing the attack surface of a database by applying security best practices: removing unnecessary features/users/sample databases changing default passwords patching known vulnerabilities disabling dangerous SQL functions restricting network access and following vendor security guidelines (e.g. CIS Benchmarks)
click to copy
What is the principle of separation of duties in database administration and how is it implemented?
A security principle that requires splitting privileged operations among multiple people so no single person can perform all steps of a sensitive operation alone - prevents insider threats and requires collusion for fraud. Implemented by: separating DBA roles (application DBA vs security DBA) keeping DBAs out of application user tables using DAM tools that DBAs cannot disable
click to copy
What is the OWASP Top 10 for databases and what are the most critical database-related web application vulnerabilities?
A list of the most critical security risks for web applications; key database-related vulnerabilities include: (1) Injection (SQL injection is most common) (2) Broken access control (unauthorized data access) (3) Security misconfiguration (default passwords public grants) (4) Sensitive data exposure (unencrypted PII) and (5) Insufficient logging and monitoring (no audit trail)
click to copy