In production systems, executing SQL is only part of the story.
Behind every operation in GBase database, there is a full lifecycle:
- A transaction begins
- Data changes are written
- Logs record every step
- The database service ensures durability
- Recovery is possible if something fails
This article connects transactions + logging + service management into one complete picture.
π§ Part 1: Transactions β The Foundation of Data Consistency
In GBase, all data operations are executed inside transactions.
Example:
BEGIN;
UPDATE users SET age = 30 WHERE id = 1;
COMMIT;
What happens:
- Transaction starts
- Data is modified
- Logs capture the change
- Commit finalizes the operation
GBase ensures ACID compliance, meaning operations are atomic and recoverable.
π§± Part 2: Logging β How GBase Tracks Every Change
GBase uses logical and physical logs to track database activity.
πΉ Logical Logs
- Record SQL-level operations
- Track transactions (INSERT / UPDATE / DELETE)
πΉ Physical Logs
- Record low-level storage changes
- Track page modifications
You can monitor logs with:
onstat -l
This shows:
- Log usage
- Number of records
- Space consumption (gbasedbt.com)
π Example Log Output
numrecs Log Space used
82067 12130972
This indicates how many operations have been recorded and how much space they consume (gbase.cn)
π What Happens During an UPDATE?
UPDATE users SET age = 30 WHERE id = 1;
Internally:
- Transaction begins
- Old data is logged
- New data is written
- Log entry is created
- Transaction commits
π If something fails, logs allow rollback or recovery.
βοΈ Part 3: Database Service Lifecycle
Transactions and logs rely on a running database engine.
π Start Database
oninit -vy
This:
- Allocates shared memory
- Loads configuration
- Initializes logs and storage
- Starts background processes (gbase.cn)
π Stop Database
onmode -ky
This:
- Terminates sessions
- Flushes logs to disk
- Ensures safe shutdown (gbasedbt.com)
π Check Status
onstat -
Example:
On-Line -- Up 00:00:14
Shows database is running normally (gbase.cn)
π Part 4: Recovery β When Things Go Wrong
Scenario: System Crash
If the database crashes:
- Restart with
oninit - GBase reads logs
- Applies committed transactions
- Rolls back incomplete ones
During startup, GBase initializes:
- Log/checkpoint information
- Storage structures
- Recovery processes (gbase.cn)
Example Error During Startup
Cannot open chunk '/path/datadbs1_1'
This indicates storage issues, but logs still help recover valid data (gbase.cn)
π Part 5: Monitoring Transactions and Logs
After heavy operations, monitoring is critical.
Check Logs
onstat -l
Check System Performance
onstat -p
Shows:
- Disk I/O
- Buffer usage
- Runtime stats (gbasedbt.com)
Check Sessions
onstat -g ses
Displays active transactions and connections (gbase.cn)
β οΈ Real-World Issues
1. Heavy Logging
Large updates:
UPDATE orders SET status = 'done';
May cause:
- High disk I/O
- Log space exhaustion
2. Lock Contention
Transactions can lock rows or tables:
- Blocking other queries
- Causing performance issues (DEV Community)
3. Startup Failures
Incorrect configuration or missing files can prevent startup.
β‘ Best Practices
β Use Transactions Explicitly
BEGIN;
UPDATE ...
COMMIT;
β Monitor Logs Regularly
onstat -l
β Ensure Proper Shutdown
onmode -ky
Avoid force killing processes.
β Watch System After Heavy Operations
onstat -p
π§ Key Insight
GBase reliability comes from the combination of three layers:
| Layer | Role |
|---|---|
| Transaction | Controls data changes |
| Logging | Records every operation |
| Service | Ensures execution & recovery |
π You need all three to work together.
π Final Thoughts
GBase is not just executing SQLβit is constantly:
- Tracking changes through logs
- Managing transactions
- Maintaining system state
- Ensuring recovery
Understanding this lifecycle helps you:
π Debug issues faster
π Prevent data loss
π Optimize performance
π¬ Key Takeaways
- Every data change is logged
- Transactions ensure consistency
- Logs enable recovery
- Service lifecycle controls everything
π₯ What to Try Next
- Run an UPDATE and observe logs with
onstat -l - Restart the database and observe recovery
- Simulate rollback scenarios
If you want, I can next generate:
- π§ͺ A hands-on lab (simulate crash + recovery step-by-step)
- π A deep dive into GBase logging internals
- β‘ Or a performance tuning guide for transactions
Top comments (0)