[Date Prev][Date Next] [Chronological] [Thread] [Top]

Replication problem



Replication works fine except when I run a perl-script which processes
the leases-file and writes them into the directory. the modifying part
of the script is attached below.

When this script is running, the add-messages are replicated without
problems, but all deletes are rejected:

ERROR: No such object
replica: 10.1.4.22:389
time: 1043159465.0
dn: macAddress=00:20:af:ca:07:ec,ou=mac,ou=Computers,dc=tgm,dc=ac,dc=at
changetype: delete

But I'm searching for the objects before deleting them, so they must exist. And since I'm running the script on only one host, it isn't possible that any other script/person/something modifies the same entries, because nobody has access to them.

Is this a speed-issue or is something wrong with my script? If it is the
script, why can a script which only updates the replication-master brake
the replication? If it is a speed-issue, what can I do against it? The
systems have a load average of 0.00, so they should have enough free
resources. Or can it be something else?

Here is the interesting part of my script, if somebody is interested
I'll post the complete script...

my $msg = $ldap->search(
	base => $LDAPBaseDN,
	scope => "sub",
	filter => "macAddress=".$lease->getHWAddress()
	);

if ( $msg->count > 0 )
{
	my $entry = $msg->pop_entry();
	if ( $lease->getAddressState =~ /free/ )
	{
		my $result;
		my $oc;
		my $olddn = $entry->dn();
		my @ocs = $entry->get_value( "objectClass" );
		$entry->delete( "cn" );
		$entry->delete( "ipHostNumber" );
		$entry->delete( "objectClass" );
		foreach $oc (@ocs)
		{
			if ( $oc =~ /ipHost/ )
			{
			}
			else
			{
				$entry->add( objectClass => $oc );
			}
		}
		$entry->dn( "macAddress=".$lease->getHWAddress().",ou=mac,$LDAPBaseDN" );
		$result = $ldap->delete( $olddn );
		$result->code && warn "failed to del entry: ".$olddn." ", $result->error;
		$result = $ldap->add( $entry );
		$result->code && warn "failed to add entry: ".$entry->dn." ", $result->error;
	}
	elsif ( $lease->getAddressState =~ /active/ )
	{
		my $result;
		my $oc;
		my $ociphost = 0;
		my $olddn = $entry->dn();
		my @ocs = $entry->get_value( "objectClass" );
		$entry->replace(
			cn		=> $lease->getIP(),
			ipHostNumber	=> $lease->getIP()
			);
		foreach $oc (@ocs)
		{
			if ( $oc =~ /ipHost/ )
			{
				$ociphost = 1;
			}
		}
		if ( !$ociphost )
		{
			$entry->add(
				objectClass	=> "ipHost"
				);
		}
		$entry->dn( "cn=".$lease->getIP().",$LDAPBaseDN" );
		$result = $ldap->delete( $olddn );
		$result->code && warn "failed to del entry: ".$olddn." ", $result->error;
		$result = $ldap->add( $entry );
		$result->code && warn "failed to add entry: ".$entry->dn." ", $result->error;
	}
	elsif ( $lease->getAddressState =~ /backup/ )
	{
		# Lease is available for allocation by the secondary
		my $result;
		my $oc;
		my $olddn = $entry->dn();
		my @ocs = $entry->get_value( "objectClass" );
		$entry->delete( "cn" );
		$entry->delete( "ipHostNumber" );
		$entry->delete( "objectClass" );
		foreach $oc (@ocs)
		{
			if ( $oc =~ /ipHost/ )
			{
			}
			else
			{
				$entry->add( objectClass => $oc );
			}
		}
		$entry->dn( "macAddress=".$lease->getHWAddress().",ou=mac,$LDAPBaseDN" );
		$result = $ldap->delete( $olddn );
		$result->code && warn "failed to del entry: ".$olddn." ", $result->error;
		$result = $ldap->add( $entry );
		$result->code && warn "failed to add entry: ".$entry->dn." ", $result->error;
	}
	else
	{
		print "TODO: ".$lease->getAddressState()."\n";
	}
}
else
{
	if ( $lease->getAddressState =~ /free/ )
	{
		my $entry = Net::LDAP::Entry->new;
		$entry->dn( "macAddress=".$lease->getHWAddress().",ou=mac,$LDAPBaseDN" );
		$entry->add(
			objectClass	=> [ "top", "ieee802Device" ]
			);
		$entry->add(
			macAddress	=> $lease->getHWAddress()
			);
		my $result = $ldap->add( $entry );
		$result->code && warn "failed to add entry: ", $result->error;
	}
	elsif ( $lease->getAddressState =~ /active/ )
	{
		my $entry = Net::LDAP::Entry->new;
		$entry->dn( "cn=".$lease->getIP().",$LDAPBaseDN" );
		$entry->add(
			objectClass	=> [ "top", "ieee802Device", "ipHost" ]
			);
		$entry->add(
			macAddress	=> $lease->getHWAddress(),
			ipHostNumber	=> $lease->getIP(),
			cn		=> $lease->getIP()
			);
		my $result = $ldap->add( $entry );
		$result->code && warn "failed to add entry: ", $result->error;
	}
	elsif ( $lease->getAddressState =~ /backup/ )
	{
		# Lease is available for allocation by the secondary
		my $entry = Net::LDAP::Entry->new;
		$entry->dn( "macAddress=".$lease->getHWAddress().",ou=mac,$LDAPBaseDN" );
		$entry->add(
			objectClass	=> [ "top", "ieee802Device" ]
			);
		$entry->add(
			macAddress	=> $lease->getHWAddress()
			);
		my $result = $ldap->add( $entry );
		$result->code && warn "failed to add entry: ", $result->error;
	}
	else
	{
		print "TODO: ".$lease->getAddressState()."\n";
	}
}

regards Markus Schabel +--------------------------------------------+ | TGM - Die Schule der Technik, IT-Service | | A-1200 Wien, Wexstrasse 19-23 | | Tel.: +43(1)33126/316 Fax: +43(1)33126/154 | | eMail: markus.schabel@tgm.ac.at | | markus.schabel@member.fsf.org | | FSF Associate Member #597 | | Linux User #259595 (http://counter.li.org) | +--------------------------------------------+

Computers are like airconditioners:
  They stop working properly if you open windows.