PHP - 如何在调用commit之后等待写入磁盘?

I'm using postgresql. I have to call a jar file that does some operations after db read, within a php script.

$connection is a PDO. I have noticed the following behavoiurs:

Scenario 1:

$connection->commit();

exec_shell(java -jar jarname) //it does not give expected behaviour

Scenario 2:

$connection->commit();

sleep(60);

exec_shell(java -jar jarname) //it does give expected behaviour

So, the question is: how to wait until commit writes all data to disk before going on with instructions?

fsync is on in postgres.conf synchronous_commit is on in postgres.conf

I have no experience with PDO but if you can check the result of a commit you can try something like this:

$commit_status = $connection->commit();
if($commit_status === TRUE)
{
  exec_shell(java -jar jarname)
}

As long as you dont have response from commit status exec_shell wont be called