In this test you will simulate a crash of the database engine service on the DB instance. This type of crash can be encountered in real circumstances as a result of out-of-memory conditions, or other unexpected circumstances.
Fault injection queries provide a mechanism to simulate a variety of faults in the operation of the DB cluster. They are used to test the tolerance of client applications to such faults. They can be used to:
In one of the two Cloud9 terminal windows, start the monitoring script using the following command:
We had set the DBENDP variable to the Aurora cluster endpoint in the step Configure Cloud9 and Initialize Database
python /home/ec2-user/simple_failover.py -e $DBENDP -u $DBUSER -p $DBPASS -d $PGDATABASE
Since we are using the cluster endpoint to connect, the motioning script is connected to the current writer node.
On the other Cloud9 terminal window, issue the following fault injection command. A crash of the PostgreSQL-compatible database for the Amazon Aurora instance will be simulated.
psql -c "SELECT aurora_inject_crash ('instance');"
Wait and observe the monitoring script output. Once the crash is triggered, you should see an output similar to the example below.
As you see above, the instance was restarted and the monitoring script reconnected after a brief interruption.
You can exit the monitoring script at this point by pressing Ctrl + c.