I have a perl script which is run parallel.
ls -lrt INCOMING | grep .out | head -${PARALLEL_COUNT} | awk '{print $9}' | parallel "./new_control.pl" {}
Script proccessing csv files which coresponds server data. When the script is running parallel I have exception
Uncaught exception from user code:
DBD::Oracle::st execute failed: ORA-00001: unique constraint (PRE.SYS_C006373) violated (DBD ERROR: OCIStmtExecute) [for Statement "INSERT INTO DISK
(
ID,
RECORD_ID,
MOUNT_POINT,
TOTAL_SIZE,
USED,
AVALIABLE,
CAPACITY,
)
VALUES ((SELECT NVL(MAX(ID)+1, 1) FROM DISK), ?, ?, ?, ?, ?, ?, ?, ?, ?)
I suppose that the problem is ID column where is inserting incremented value.
(SELECT NVL(MAX(ID)+1, 1)
and the same id is already also inserting by the other script instance.
I tried to change AutoCommit but without any positive result
our $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid;port=$port", $username, $password,
{
RaiseError => 1,
AutoCommit => 1 # this will need to call commit manually (if value is 0) after changes in DB.
});
When the script is not run parallel everythink is ok. I don't want to generate those id's before I run the script parallely.