Tag Archives: br8dba

WAL Commit Process

PostgreSQL WAL Commit Process

1. The Modification (In-Memory)

When a user executes a data-modifying query (like INSERT, UPDATE, or DELETE):

  • The change is made to the table or index data inside the Shared Buffers (RAM). The page in memory is now marked as “dirty.”

  • Simultaneously, a record of this exact change is constructed and written sequentially into the WAL Buffers (also in RAM).

2. The COMMIT Command Issued

When the client sends the COMMIT command, PostgreSQL must guarantee that this change will survive a sudden power outage or crash before it can tell the user “Success.”

3. Flushing to Disk (XLogFlush)

To ensure durability without the massive overhead of writing entire data pages to disk immediately, Postgres uses the Write-Ahead Logging protocol:

  • The internal function XLogFlush() is called.

  • It identifies the exact position (Log Sequence Number, or LSN) of the commit record in the WAL Buffer.

  • It issues a synchronous write to flush all WAL buffers up to that LSN out of RAM and into the current 16MB WAL segment file on permanent storage.

  • An fsync() system call is issued to ensure the OS cache actually commits the data to physical disk platters or flash memory.

4. Acknowledgment to the Client

Once the operating system confirms that the WAL record is safely written to the physical storage, the transaction status is updated to “committed” in the commit log (CLOG), and PostgreSQL sends a success acknowledgment back to the client application.

Crucial Architectural Concepts

  • Write-Ahead Rule: The core rule of WAL is that changes to data pages must not be written to permanent database files on disk until the log records describing those changes have been flushed to stable storage. If the server crashes, Postgres reads the WAL from the last checkpoint forward and reapplies the changes (“redoes” them).

  • Asynchronous Commit Alternative: If you set the configuration parameter synchronous_commit = off, Postgres will acknowledge the client’s COMMIT before the WAL buffer is flushed to disk (relying on the WAL Writer background process to flush it within roughly 3 times wal_writer_delay). This massively increases write throughput but introduces a risk of losing up to a split-second of recent transactions if the server suddenly loses power.

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.
Thank you
Rajasekhar Amudala

DBT-06103 The port (1,522) is already used

DBT-06103: The port (1522) is already in use

Issue: 

Error encountered while creating a database using DBCA.

Solution

1. Identify who is using port 1522

Port Check Screenshot

It appears that no process is using port 1522.

2. Verify /etc/hosts entries

[root@lxtrdedbpsgv05 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Observation: Host entry is missing in /etc/hosts, which is causing the issue.

3. Add host entry to /etc/hosts

[root@lxtrdedbpsgv05 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# DB Server
192.168.2.56    lxtrdedbpsgv05.rajasekhar.com   lxtrdedbpsgv05

Result: After adding the host entry, the issue has been resolved successfully.

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Windows Server 2022 Failover Cluster

Windows Server 2022 Failover Cluster using PowerShell
for SQL Server Always On Availability Groups

Table of Contents



0. Environment

NodeHostnameIP Address
DB Node 1NTICBPSQLSGV01192.168.2.21
DB Node 2NTICBPSQLSGV02192.168.2.22
DB Node 3NTICBPSQLSGV03192.168.2.23
DB Node 4NTICBPSQLSGV04192.168.2.24
Cluster NameNTICBPSQLSGC05192.168.2.25
DCDC01192.168.2.20

1. Prerequisites

  • All four servers must run Windows Server 2022.
  • All servers must be joined to the same Active Directory domain.
  • Ensure proper DNS name resolution between all nodes.
  • Verify network connectivity and configure static IP addresses.
  • Install the latest Windows updates and vendor drivers.

2. Install Failover Clustering Feature

Run the following command on each node as Administrator.

On NTICBPSQLSGV01

PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV01
PS C:\Users\Administrator>
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed

PS C:\Users\Administrator>

On NTICBPSQLSGV02

PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV02
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed


PS C:\Users\Administrator>

On NTICBPSQLSGV03

PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV03
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed

PS C:\Users\Administrator>

On NTICBPSQLSGV04

PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV04
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed


PS C:\Users\Administrator>
✔ Failover Clustering feature installed successfully on all nodes.

 

3. Import Cluster Module and Validate Cluster Configuration

On NTICBPSQLSGV01

Load the Windows Failover Clustering PowerShell module into your current PowerShell session.
Run validation before creating the cluster:

On NTICBPSQLSGV01:

PS C:\Users\Administrator> hostname
NTICBPSQLSGV01
PS C:\Users\Administrator> Import-Module FailoverClusters
PS C:\Users\Administrator>

PS C:\Users\Administrator> Test-Cluster -Node NTICBPSQLSGV01,NTICBPSQLSGV02,NTICBPSQLSGV03,NTICBPSQLSGV04
WARNING: System Configuration - Validate Software Update Levels: The test reported some warnings..
WARNING: Network - Validate Network Communication: The test reported some warnings..
WARNING:
Test Result:
HadUnselectedTests, ClusterConditionallyApproved
Testing has completed for the tests you selected. You should review the warnings in the Report.  A cluster solution is
supported by Microsoft only if you run all cluster validation tests, and all tests succeed (with or without warnings).
Test report file path: C:\Users\Administrator\AppData\Local\Temp\2\Validation Report 2025.12.29 At 18.28.44.htm

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        12/29/2025   6:34 PM        1346352 Validation Report 2025.12.29 At 18.28.44.htm


PS C:\Users\Administrator>

Note: Warnings are acceptable, but errors must be resolved.
Always review the cluster validation report.

 

4. Create the Cluster

New-Cluster `
 -Name NTICBPSQLSGC05 `
 -Node NTICBPSQLSGV01,NTICBPSQLSGV02,NTICBPSQLSGV03,NTICBPSQLSGV04 `
 -StaticAddress 192.168.2.25 `
 -NoStorage

PS C:\Users\Administrator> New-Cluster `
>>  -Name NTICBPSQLSGC05 `
>>  -Node NTICBPSQLSGV01,NTICBPSQLSGV02,NTICBPSQLSGV03,NTICBPSQLSGV04 `
>>  -StaticAddress 192.168.2.25 `
>>  -NoStorage

Name
----
NTICBPSQLSGC05


PS C:\Users\Administrator>
✔ Cluster NTICBPSQLSGC05 created successfully.

 

5. Verify Cluster Configuration

Cluster Name

PS C:\Users\Administrator> Get-Cluster

Name
----
NTICBPSQLSGC05


PS C:\Users\Administrator>

Cluster Nodes

PS C:\Users\Administrator> Get-ClusterNode

Name           State Type
----           ----- ----
NTICBPSQLSGV01 Up    Node
NTICBPSQLSGV02 Up    Node
NTICBPSQLSGV03 Up    Node
NTICBPSQLSGV04 Up    Node


PS C:\Users\Administrator>

Cluster Resources

PS C:\Users\Administrator> Get-ClusterResource

Name               State  OwnerGroup    ResourceType
----               -----  ----------    ------------
Cluster IP Address Online Cluster Group IP Address
Cluster Name       Online Cluster Group Network Name


PS C:\Users\Administrator>

Cluster Network

PS C:\Users\Administrator> Get-ClusterNetwork | Format-Table Name, Address, Role, State

Name              Address                 Role State
----              -------                 ---- -----
Cluster Network 1 192.168.2.0 ClusterAndClient    Up


PS C:\Users\Administrator>
✔ All cluster components are online and healthy.

6. Add Witness

In this test lab environment, the File Share Witness (FSW) is hosted on the Domain Controller (DC).

Using a Domain Controller as File Share Witness is NOT recommended for production.

  • In production, the File Share Witness should be hosted on:
    • A dedicated file server
    • Azure Cloud Witness (recommended)
  • The witness folder must have Full Control for:
    • The Windows Failover Cluster computer object
    • SQL Server Always On cluster name object
       

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Post #7

BRIGHT DBA · Independent DBA Consultant

24/7 Managed Database Services

Remote DBA services from an independent senior Oracle and PostgreSQL consultant: monitoring, backup, patching, tuning, high availability and migration, with a DBA you can talk to directly.

OraclePostgreSQLReliableSecureScalable

What you get

  • Round-the-clock monitoring and alerting
  • Fast response when something breaks
  • Tested backups and recovery
  • A predictable monthly cost instead of a full-time hire
  • A senior DBA who knows your systems
What We Manage

Everything your databases need to stay healthy

One person responsible for availability, performance and recoverability, so problems are caught before your users notice them.

📡

24/7 Monitoring & Alerting

Continuous checks on availability, space, sessions, locks, replication lag and slow queries, with alerts that reach a person.

💾

Backup & Recovery

Backup strategy, verification and regular restore tests with RMAN, pgBackRest and point-in-time recovery.

🔧

Patching & Upgrades

Planned patching and version upgrades with rollback plans and minimal downtime.

🚀

Performance Tuning

Find and fix slow SQL, tune statistics, memory and I/O, and keep performance steady as data grows.

🛡️

High Availability & DR

Data Guard, RAC, Patroni and repmgr, designed, built and tested with switchover drills.

🔁

Migrations

Zero-downtime migrations with GoldenGate, between versions and platforms, including Oracle to PostgreSQL.

Our Specialities

Deep expertise where it matters

🔴

Oracle

RAC, Data Guard, GoldenGate, Exadata, multitenant, RMAN backup and recovery, patching, upgrades and performance tuning.

View Oracle DBA services →
🐘

PostgreSQL

Patroni, repmgr, HAProxy and pgBackRest, streaming replication, point-in-time recovery, tuning and version upgrades.

View PostgreSQL DBA services →
🔀

Oracle to PostgreSQL Migration

Cut licence costs by moving to PostgreSQL. We assess, plan and migrate your databases with minimal downtime.

Learn more →
How We Support You

Clear, direct and easy to work with

💬

Direct chat channel

A WhatsApp or Slack channel for quick questions and updates, so you talk to the DBA, not a ticket queue.

📞

Incident calls

When something critical breaks, we join a live call on Zoom or Meet and work the problem with your team.

📊

Monthly health report

A clear report on performance, capacity, backups and risks, with recommendations.

🔐

Security & access review

Regular checks of users, privileges and patch levels to keep your databases safe.

📘

Runbooks & documentation

Your procedures documented, so recovery and routine tasks do not depend on one person.

⏱️

Agreed response targets

Response times are agreed per plan, matched to how critical each database is.

Service Plans

Choose the level of cover you need

Every plan is scoped to your environment. Pricing is a custom quote, and response targets are agreed per plan.

Essential

Business-hours care

For smaller environments that need regular attention.

  • Monitoring during business hours
  • Daily backup checks
  • Monthly health report
  • Email and WhatsApp support
Standard · Most popular

24/7 coverage

For production systems that cannot go down.

  • 24/7 monitoring and alerting
  • Incident response with agreed targets
  • Planned patching and maintenance
  • Monthly review with recommendations
Premium

Proactive and complete

For critical, high-availability databases.

  • Everything in Standard
  • Proactive performance tuning
  • Disaster recovery drills
  • Priority response and named DBA
How It Works

Up and running in four steps

1

Book a call

Tell us about your databases and what worries you.

2

Assessment

We review your databases and agree the scope and plan with you.

3

Onboarding

We set up monitoring, access and runbooks, then take over.

4

We run it

We watch, maintain and report on your databases every month.

FAQ

Frequently asked questions

What is included in a managed database plan?

Depending on the plan: monitoring, backup checks, patching, performance tuning and regular reports. We agree the exact scope with you before we start.

What response time do you offer?

Response targets are agreed per plan, based on how critical your databases are to your business.

Which databases do you manage?

Oracle (including RAC, Data Guard, GoldenGate and Exadata) and PostgreSQL.

Can you help us migrate from Oracle to PostgreSQL?

Yes. We assess your Oracle databases, plan the move and carry it out with minimal downtime, using the tools that suit your case.

How do you handle backups and recovery?

We set up and monitor backups, for example RMAN for Oracle and pgBackRest for PostgreSQL, and we test restores regularly so recovery is proven, not assumed.

How do you access our systems, and is it secure?

Access is agreed up front, through your VPN or bastion host, with named accounts and the least privileges needed. Confidentiality terms are part of the agreement.

Do you work with databases in the cloud?

We can manage databases running on cloud servers. Tell us your setup and we will confirm what we can support.

How do we get started?

Book a call or send us a message. We begin with an assessment of your environment and then propose a plan.

Talk to Us

Let us look after your databases

Book a call, or tell us what you run and what keeps you up at night. We will get back to you soon with a proposal.

Tell us what you need

💬