0

I have encountered a strange behavior in mysql, using dbi in Perl.

At the end of a perl program, I issue a mysql UPDATE command to a table. The command is executed using $dbh->execute(); and autocommit is turned on. After the execute, the program issues $dbh->disconnect(); and exits.

The perl program runs as part of a script. Immediately when the perl program has stopped, another script executes. This script looks as the table that was updated, and here is when things become confusing to me.

Sometimes script 2 reads the old data in the table. Sometimes it sees what was just updated. I cannot understand how the initial perl program can do the $dbh->execute(); and yet it seems that the mysql table is updated several seconds later.

Any insight would be helpful! Cheers in advance.

1 Answers1

2

Turns out the problem was never with either mysql or Perl.

The problem was that the two scripts were running as a script called by a crontab job. Unless specified, crontab did not run using the bash shell.

See https://askubuntu.com/questions/117978/script-doesnt-run-via-crontab-but-works-fine-standalone

for more information.