ocsinventory-server-2.0.5 session.pm breaks mysql replication of ocsweb db

Bug #1154646 reported by Pieter-Jan Gunst
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OCS Inventory: Server
Incomplete
Medium
mortheres

Bug Description

package Apache::Ocsinventory::Server::Communication::Session

if the below code is executed...
> # To avoid race conditions
> if( !$dbh->do("INSERT INTO engine_mutex(NAME, PID, TAG) VALUES('SESSION',?,'CLEAN')", {}, $$) ){
> &_log(315,'session',"already handled") if $ENV{'OCS_OPT_LOGLEVEL'};
> return;

and replicated to a slave db, it will also attempt to execute this query. as there's a primary key on name and tag, it would be safer to check whether we already have any records with that name and tag. Here's how I worked around the issue:

< my $check_clean_exists = $dbh->prepare('SELECT * from engine_mutex where NAME="SESSION" AND TAG="CLEAN"');
< if($check_clean_exists->execute() && !$check_clean_exists->rows()){
< $dbh->do('DELETE FROM engine_mutex WHERE NAME="SESSION" AND TAG="CLEAN"', {}, $$ );
< &_log(312,'session', "deleted") if $ENV{'OCS_OPT_LOGLEVEL'};
< $dbh->do("INSERT INTO engine_mutex(NAME, PID, TAG) VALUES('SESSION',?,'CLEAN')", {}, $$);
< &_log(313,'session', "started") if $ENV{'OCS_OPT_LOGLEVEL'};

you could as well just log and return, but I leave that up to you ocs experts.

affects: ocsinventory-deploy-tool → ocsinventory-server
Changed in ocsinventory-server:
assignee: nobody → mortheres (mortheres)
Revision history for this message
mortheres (mortheres) wrote :

Hi,

I was not able to reproduce the problem using a MySQL slave server. Can you tell me on which case the problem happens ? On most of the computers inventories ? In standard case, the "INSERT INTO" request should only be executed on master server not on the slave.

Kind regards,

--
Guillaume

mortheres (mortheres)
Changed in ocsinventory-server:
importance: Undecided → Medium
mortheres (mortheres)
Changed in ocsinventory-server:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.