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)