databases
9 minStored Functions, Procedures, and Triggers: Put Logic in the Right Layer
Compare database routines and triggers with application services, focusing on transaction ownership, portability, and operational visibility.
Loading page...
databases
9 minCompare database routines and triggers with application services, focusing on transaction ownership, portability, and operational visibility.
Q&A
Q&AThe statement has side effects that are not visible at its call site.
A trigger can modify other rows or tables implicitly during an insert or update. That makes the visible application statement an incomplete description of the transaction and can add locking or recursion. Document and test trigger effects, or move orchestration to an explicit routine/service when hidden behavior harms operability.
Q&A
Q&ACPU can be throttled; exceeding a memory limit can trigger an OOM kill.
CPU usage above a configured limit is throttled, which can increase latency without stopping the process. Memory is not throttled in the same way: crossing the container limit can cause the kernel to kill the process, often reported as OOMKilled. Requests affect scheduling and utilization-based HPA calculations, so tune all values from observed workload behavior.
Q&A
Q&Agrep returns status 1 when there are no matches, which may trigger strict shell error handling.
grep commonly exits 0 when it finds a match, 1 when it finds none, and 2 for an error. With `set -e`, an expected no-match status can terminate a script unless handled intentionally. Distinguish absence from malformed input or permission failures rather than suppressing every status.
Q&A
Q&Aepoll tracks interest and reports readiness changes instead of requiring repeated full-set scans.
select requires rebuilding and scanning descriptor sets on each wait and has platform-specific descriptor limits; poll also examines a supplied list. epoll maintains kernel-side interest and ready structures, which suits large mostly-idle sets. It does not remove per-connection memory costs, application scheduling, or edge-triggered drain requirements.
Q&A
Q&AFunctions typically return values; procedures are invoked as operations, with engine-specific transaction rules.
A function is commonly used as an expression or query result and returns a value or table. A procedure is invoked to perform an operation and may accept output parameters. Triggers run implicitly. Transaction control differs by engine, so keep commit ownership explicit and test routines against the target database/version.
Q&A
Q&ACompletion stages form a dependency graph; blocking the wrong executor can starve that graph.
CompletableFuture represents a value that may complete later, with dependent stages triggered on completion. Async methods without an explicit executor commonly use a shared pool; blocking calls there can starve unrelated work. Prefer non-blocking composition, choose an executor suited to the task, set timeouts, and observe exceptional completion rather than calling join() throughout request paths.
devops
5 minReconstruct a deployment incident without mistaking log delivery order or clock skew for causal ordering.