1820. [bug] razvan
- Fixed lease update when using hooks with database backend.
- Previously, HA updates were rejected because the database
- backend rejects operations on the lease if lease old expire
- is different than what is already stored, to act as a
- protection mechanism for parallel updates from several threads
- or processes.
+ Fixed lease update when using HA and lease_cmds hooks with
+ database backend. Previously, HA updates were rejected because
+ the database backend rejects operations on the lease if the old
+ expiration time is different than what it is already stored, to
+ act as a protection mechanism for parallel updates from several
+ threads or processes.
(Gitlab #1434)
1819. [func] fdupont
} else if (existing_lease->cltt_ < lease->cltt_) {
// If the existing lease is older than the fetched lease, update
// the lease in our local database.
- // Update lease old expire with value received from the database.
- // Some database backends reject operations on the lease if the
- // old expire value does not match what is stored.
- Lease::syncExistingLifetime(*existing_lease, *lease);
+ // Update lease current expiration time with value received from the
+ // database. Some database backends reject operations on the lease if
+ // the current expiration time value does not match what is stored.
+ Lease::syncCurrentExpirationTime(*existing_lease, *lease);
LeaseMgrFactory::instance().updateLease4(lease);
} else {
} else if (existing_lease->cltt_ < lease->cltt_) {
// If the existing lease is older than the fetched lease, update
// the lease in our local database.
- // Update lease old expire with value received from the database.
- // Some database backends reject operations on the lease if the
- // old expire value does not match what is stored.
- Lease::syncExistingLifetime(*existing_lease, *lease);
+ // Update lease current expiration time with value received from the
+ // database. Some database backends reject operations on the lease if
+ // the current expiration time value does not match what is stored.
+ Lease::syncCurrentExpirationTime(*existing_lease, *lease);
LeaseMgrFactory::instance().updateLease6(lease);
} else {
return (true);
}
if (existing) {
- // Update lease old expire with value received from the database.
- // Some database backends reject operations on the lease if the
- // old expire value does not match what is stored.
- Lease::syncExistingLifetime(*existing, *lease);
+ // Update lease current expiration time with value received from the
+ // database. Some database backends reject operations on the lease if
+ // the current expiration time value does not match what is stored.
+ Lease::syncCurrentExpirationTime(*existing, *lease);
}
try {
LeaseMgrFactory::instance().updateLease4(lease);
return (true);
}
if (existing) {
- // Update lease old expire with value received from the database.
- // Some database backends reject operations on the lease if the
- // old expire value does not match what is stored.
- Lease::syncExistingLifetime(*existing, *lease);
+ // Update lease current expiration time with value received from the
+ // database. Some database backends reject operations on the lease if
+ // the current expiration time value does not match what is stored.
+ Lease::syncCurrentExpirationTime(*existing, *lease);
}
try {
LeaseMgrFactory::instance().updateLease6(lease);
// expiration time is cast properly.
lease->valid_lft_ = HIGH_VALID_LIFETIME; // Very high valid lifetime
lease->cltt_ = DEC_2030_TIME; // December 11th 2030
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
if (declined) {
lease->state_ = Lease::STATE_DECLINED;
}
// expiration time is cast properly.
lease->valid_lft_ = HIGH_VALID_LIFETIME; // Very high valid lifetime
lease->cltt_ = DEC_2030_TIME; // December 11th 2030
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
if (declined) {
lease->state_ = Lease::STATE_DECLINED;
}
///
/// @param connection already open Cassandra connection.
CqlLeaseExchange(const CqlConnection &connection)
- : connection_(connection), valid_lifetime_(0), expire_(0), old_expire_(0),
- subnet_id_(0), fqdn_fwd_(cass_false), fqdn_rev_(cass_false),
- state_(0), user_context_(NULL_USER_CONTEXT) {
+ : connection_(connection), valid_lifetime_(0), expire_(0),
+ current_expire_(0), subnet_id_(0), fqdn_fwd_(cass_false),
+ fqdn_rev_(cass_false), state_(0), user_context_(NULL_USER_CONTEXT) {
}
/// @brief Create BIND array to receive C++ data.
cass_int64_t expire_;
/// @brief Expiration time of lease before update
- cass_int64_t old_expire_;
+ cass_int64_t current_expire_;
/// @brief Subnet identifier
cass_int32_t subnet_id_;
data.add(&user_context_);
data.add(&address_);
- CqlExchange::convertToDatabaseTime(lease_->old_cltt_, lease_->old_valid_lft_,
- old_expire_);
- data.add(&old_expire_);
+ CqlExchange::convertToDatabaseTime(lease_->current_cltt_,
+ lease_->current_valid_lft_,
+ current_expire_);
+ data.add(¤t_expire_);
} catch (const Exception &ex) {
isc_throw(DbOperationError,
"CqlLease4Exchange::createBindUpdate(): "
data.clear();
data.add(&address_);
- CqlExchange::convertToDatabaseTime(lease_->old_cltt_, lease_->old_valid_lft_,
- old_expire_);
- data.add(&old_expire_);
+ CqlExchange::convertToDatabaseTime(lease_->current_cltt_,
+ lease_->current_valid_lft_,
+ current_expire_);
+ data.add(¤t_expire_);
} catch (const Exception &ex) {
isc_throw(DbOperationError,
"CqlLease4Exchange::createBindForDelete(): "
data.add(&user_context_);
data.add(&address_);
- CqlExchange::convertToDatabaseTime(lease_->old_cltt_, lease_->old_valid_lft_,
- old_expire_);
- data.add(&old_expire_);
+ CqlExchange::convertToDatabaseTime(lease_->current_cltt_,
+ lease_->current_valid_lft_,
+ current_expire_);
+ data.add(¤t_expire_);
} catch (const Exception &ex) {
isc_throw(DbOperationError,
"CqlLease6Exchange::createBindForUpdate(): "
data.clear();
data.add(&address_);
- CqlExchange::convertToDatabaseTime(lease_->old_cltt_, lease_->old_valid_lft_,
- old_expire_);
- data.add(&old_expire_);
+ CqlExchange::convertToDatabaseTime(lease_->current_cltt_,
+ lease_->current_valid_lft_,
+ current_expire_);
+ data.add(¤t_expire_);
} catch (const Exception &ex) {
isc_throw(DbOperationError,
"CqlLease6Exchange::createBindForDelete(): "
time_t cltt = 0;
CqlExchange::convertFromDatabaseTime(expire_, valid_lifetime_, cltt);
- // Update cltt_ and old_cltt_ explicitly.
+ // Update cltt_ and current_cltt_ explicitly.
result->cltt_ = cltt;
- result->old_cltt_ = cltt;
+ result->current_cltt_ = cltt;
result->state_ = state_;
return false;
}
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return true;
}
return false;
}
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return true;
}
isc_throw(NoSuchLease, exception.what());
}
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
}
void
isc_throw(NoSuchLease, exception.what());
}
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
}
bool
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The UPDATE query uses IF expire = ? to update the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and UPDATE.
+ /// enforcing no update on the lease between SELECT and UPDATE with
+ /// different expiration time.
virtual void updateLease4(const Lease4Ptr& lease4) override;
/// @brief Updates IPv6 lease.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The UPDATE query uses IF expire = ? to update the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and UPDATE.
+ /// enforcing no update on the lease between SELECT and UPDATE with
+ /// different expiration time.
virtual void updateLease6(const Lease6Ptr& lease6) override;
/// @brief Deletes an IPv4 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The DELETE query uses IF expire = ? to delete the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and DELETE.
+ /// enforcing no update on the lease between SELECT and DELETE with
+ /// different expiration time.
bool deleteLease(const Lease4Ptr& lease) override final;
/// @brief Deletes an IPv6 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The DELETE query uses IF expire = ? to delete the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and DELETE.
+ /// enforcing no update on the lease between SELECT and DELETE with
+ /// different expiration time.
bool deleteLease(const Lease6Ptr& lease) override final;
/// @brief Deletes all expired and reclaimed DHCPv4 leases.
uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
const bool fqdn_fwd, const bool fqdn_rev,
const std::string& hostname, const HWAddrPtr& hwaddr)
- : addr_(addr), valid_lft_(valid_lft), old_valid_lft_(valid_lft),
- cltt_(cltt), old_cltt_(cltt), subnet_id_(subnet_id),
+ : addr_(addr), valid_lft_(valid_lft), current_valid_lft_(valid_lft),
+ cltt_(cltt), current_cltt_(cltt), subnet_id_(subnet_id),
hostname_(boost::algorithm::to_lower_copy(hostname)), fqdn_fwd_(fqdn_fwd),
fqdn_rev_(fqdn_rev), hwaddr_(hwaddr), state_(STATE_DEFAULT) {
}
lease->setContext(ctx);
}
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
}
void
-Lease::updateExistingLifetime() {
- Lease::syncExistingLifetime(*this, *this);
+Lease::updateCurrentExpirationTime() {
+ Lease::syncCurrentExpirationTime(*this, *this);
}
void
-Lease::syncExistingLifetime(const Lease& from, Lease& to) {
- to.old_cltt_ = from.cltt_;
- to.old_valid_lft_ = from.valid_lft_;
+Lease::syncCurrentExpirationTime(const Lease& from, Lease& to) {
+ to.current_cltt_ = from.cltt_;
+ to.current_valid_lft_ = from.valid_lft_;
}
Lease4::Lease4(const Lease4& other)
if (this != &other) {
addr_ = other.addr_;
valid_lft_ = other.valid_lft_;
- old_valid_lft_ = other.old_valid_lft_;
+ current_valid_lft_ = other.current_valid_lft_;
cltt_ = other.cltt_;
- old_cltt_ = other.old_cltt_;
+ current_cltt_ = other.current_cltt_;
subnet_id_ = other.subnet_id_;
hostname_ = other.hostname_;
fqdn_fwd_ = other.fqdn_fwd_;
}
cltt_ = time(NULL);
- old_cltt_ = cltt_;
+ current_cltt_ = cltt_;
}
Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr,
}
cltt_ = time(NULL);
- old_cltt_ = cltt_;
+ current_cltt_ = cltt_;
}
Lease6::Lease6()
addr_ == other.addr_ &&
subnet_id_ == other.subnet_id_ &&
valid_lft_ == other.valid_lft_ &&
- old_valid_lft_ == other.old_valid_lft_ &&
+ current_valid_lft_ == other.current_valid_lft_ &&
cltt_ == other.cltt_ &&
- old_cltt_ == other.old_cltt_ &&
+ current_cltt_ == other.current_cltt_ &&
hostname_ == other.hostname_ &&
fqdn_fwd_ == other.fqdn_fwd_ &&
fqdn_rev_ == other.fqdn_rev_ &&
iaid_ == other.iaid_ &&
preferred_lft_ == other.preferred_lft_ &&
valid_lft_ == other.valid_lft_ &&
- old_valid_lft_ == other.old_valid_lft_ &&
+ current_valid_lft_ == other.current_valid_lft_ &&
cltt_ == other.cltt_ &&
- old_cltt_ == other.old_cltt_ &&
+ current_cltt_ == other.current_cltt_ &&
subnet_id_ == other.subnet_id_ &&
hostname_ == other.hostname_ &&
fqdn_fwd_ == other.fqdn_fwd_ &&
/// @param hostname FQDN of the client which gets the lease.
/// @param hwaddr Hardware/MAC address
///
- /// @note When creating a new Lease object, old_cltt_ matches cltt_ and
- /// old_valid_lft_ matches valid_lft_. Any update operation that changes
- /// cltt_ or valid_lft_ in the database must also update the old_cltt_ and
- /// old_valid_lft_ after the database response so that additional operations
- /// can be performed on the same object. Failing to do so will result in
- /// the new actions to be rejected by the database.
+ /// @note When creating a new Lease object, current_cltt_ matches cltt_ and
+ /// current_valid_lft_ matches valid_lft_. Any update operation that changes
+ /// cltt_ or valid_lft_ in the database must also update the current_cltt_
+ /// and current_valid_lft_ after the database response so that additional
+ /// operations can be performed on the same object. Failing to do so will
+ /// result in the new actions to be rejected by the database.
Lease(const isc::asiolink::IOAddress& addr,
uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
const bool fqdn_fwd, const bool fqdn_rev,
/// Expressed as number of seconds since cltt.
uint32_t valid_lft_;
- /// @brief Old valid lifetime
+ /// @brief Current valid lifetime
///
/// Expressed as number of seconds since cltt before update.
- uint32_t old_valid_lft_;
+ uint32_t current_valid_lft_;
/// @brief Client last transmission time
///
/// client was received.
time_t cltt_;
- /// @brief Old client last transmission time
+ /// @brief Current client last transmission time
///
/// Specifies a timestamp giving the time when the last transmission from a
/// client was received before update.
- time_t old_cltt_;
+ time_t current_cltt_;
/// @brief Subnet identifier
///
/// Avoid a clang spurious error
using isc::data::CfgToElement::toElement;
- /// Sync lease lifetime with value of a newer version of the lease, so that
- /// additional operations can be done without performing extra read from the
- /// database.
+ /// Sync lease current expiration time with new value from another lease,
+ /// so that additional operations can be done without performing extra read
+ /// from the database.
///
- /// @note The old lease lifetime is represented by the @ref old_cltt_ and
- /// @ref old_valid_lft_ and the new lifetime by @ref cltt_ and
- /// @ref valid_lft_
+ /// @note The lease current expiration time is represented by the
+ /// @ref current_cltt_ and @ref current_valid_lft_ and the new value by
+ /// @ref cltt_ and @ref valid_lft_
///
- /// @param from The lease with latest value of lifetime.
+ /// @param from The lease with latest value of expiration time.
/// @param [out] to The lease that needs to be updated.
- static void syncExistingLifetime(const Lease& from, Lease& to);
+ static void syncCurrentExpirationTime(const Lease& from, Lease& to);
- /// Update lifetime with new value, so that additional operations can be
- /// done without performing extra read from the database.
+ /// Update lease current expiration time with new value,
+ /// so that additional operations can be done without performing extra read
+ /// from the database.
///
- /// @note The old lease lifetime is represented by the @ref old_cltt_ and
- /// @ref old_valid_lft_ and the new lifetime by @ref cltt_ and
- /// @ref valid_lft_
- void updateExistingLifetime();
+ /// @note The lease current expiration time is represented by the
+ /// @ref current_cltt_ and @ref current_valid_lft_ and the new value by
+ /// @ref cltt_ and @ref valid_lft_
+ void updateCurrentExpirationTime();
protected:
storage4_.insert(lease);
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return (true);
}
storage6_.insert(lease);
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return (true);
}
if (lease_it == index.end()) {
isc_throw(NoSuchLease, "failed to update the lease with address "
<< lease->addr_ << " - no such lease");
- } else if ((!persist) && (((*lease_it)->cltt_ != lease->old_cltt_) ||
- ((*lease_it)->valid_lft_ != lease->old_valid_lft_))) {
+ } else if ((!persist) && (((*lease_it)->cltt_ != lease->current_cltt_) ||
+ ((*lease_it)->valid_lft_ != lease->current_valid_lft_))) {
// For test purpose only: check that the lease has not changed in
// the database.
isc_throw(NoSuchLease, "failed to update the lease with address "
lease_file4_->append(*lease);
}
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
// Use replace() to re-index leases.
index.replace(lease_it, Lease4Ptr(new Lease4(*lease)));
if (lease_it == index.end()) {
isc_throw(NoSuchLease, "failed to update the lease with address "
<< lease->addr_ << " - no such lease");
- } else if ((!persist) && (((*lease_it)->cltt_ != lease->old_cltt_) ||
- ((*lease_it)->valid_lft_ != lease->old_valid_lft_))) {
+ } else if ((!persist) && (((*lease_it)->cltt_ != lease->current_cltt_) ||
+ ((*lease_it)->valid_lft_ != lease->current_valid_lft_))) {
// For test purpose only: check that the lease has not changed in
// the database.
isc_throw(NoSuchLease, "failed to update the lease with address "
lease_file6_->append(*lease);
}
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
// Use replace() to re-index leases.
index.replace(lease_it, Lease6Ptr(new Lease6(*lease)));
} else {
// For test purpose only: check that the lease has not changed in
// the database.
- if (((*l)->cltt_ != lease->old_cltt_) ||
- ((*l)->valid_lft_ != lease->old_valid_lft_)) {
+ if (((*l)->cltt_ != lease->current_cltt_) ||
+ ((*l)->valid_lft_ != lease->current_valid_lft_)) {
return false;
}
}
} else {
// For test purpose only: check that the lease has not changed in
// the database.
- if (((*l)->cltt_ != lease->old_cltt_) ||
- ((*l)->valid_lft_ != lease->old_valid_lft_)) {
+ if (((*l)->cltt_ != lease->current_cltt_) ||
+ ((*l)->valid_lft_ != lease->current_valid_lft_)) {
return false;
}
}
///
/// @throw NoSuchLease if there is no such lease to be updated.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the update
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and UPDATE.
+ /// SELECT and UPDATE with different expiration time.
virtual void updateLease4(const Lease4Ptr& lease4);
/// @brief Updates IPv6 lease.
///
/// @throw NoSuchLease if there is no such lease to be updated.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the update
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and UPDATE.
+ /// SELECT and UPDATE with different expiration time.
virtual void updateLease6(const Lease6Ptr& lease6);
/// @brief Deletes an IPv4 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the deletion
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and DELETE.
+ /// SELECT and DELETE with different expiration time.
virtual bool deleteLease(const Lease4Ptr& lease);
/// @brief Deletes an IPv6 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the deletion
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and DELETE.
+ /// SELECT and DELETE with different expiration time.
virtual bool deleteLease(const Lease6Ptr& lease);
/// @brief Deletes all expired-reclaimed DHCPv4 leases.
///
/// @throw NoSuchLease if there is no such lease to be updated.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the update
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and UPDATE.
+ /// SELECT and UPDATE with different expiration time.
void updateLease4Internal(const Lease4Ptr& lease4);
/// @brief Updates IPv6 lease.
///
/// @throw NoSuchLease if there is no such lease to be updated.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the update
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and UPDATE.
+ /// SELECT and UPDATE with different expiration time.
void updateLease6Internal(const Lease6Ptr& lease6);
/// @brief Deletes an IPv4 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the deletion
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and DELETE.
+ /// SELECT and DELETE with different expiration time.
bool deleteLeaseInternal(const Lease4Ptr& addr);
/// @brief Deletes an IPv6 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note For test purposes only, when persistence is disabled, the deletion
/// of the lease is performed only if the value matches the one received on
/// the SELECT query, effectively enforcing no update on the lease between
- /// SELECT and DELETE.
+ /// SELECT and DELETE with different expiration time.
bool deleteLeaseInternal(const Lease6Ptr& addr);
/// @brief Removes specified IPv4 leases.
valid_lft = 0;
}
MySqlConnection::convertFromDatabaseTime(expire_, valid_lft, cltt);
- // Update cltt_ and old_cltt_ explicitly.
+ // Update cltt_ and current_cltt_ explicitly.
result->cltt_ = cltt;
- result->old_cltt_ = cltt;
+ result->current_cltt_ = cltt;
// Set state.
result->state_ = state_;
// ... and drop to common code.
auto result = addLeaseCommon(ctx, INSERT_LEASE4, bind);
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return (result);
}
// ... and drop to common code.
auto result = addLeaseCommon(ctx, INSERT_LEASE6, bind);
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return (result);
}
bind.push_back(inbind[0]);
MYSQL_TIME expire;
- MySqlConnection::convertToDatabaseTime(lease->old_cltt_, lease->old_valid_lft_,
+ MySqlConnection::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_,
expire);
inbind[1].buffer_type = MYSQL_TYPE_TIMESTAMP;
inbind[1].buffer = reinterpret_cast<char*>(&expire);
// Drop to common update code
updateLeaseCommon(ctx, stindex, &bind[0], lease);
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
}
void
bind.push_back(inbind[0]);
MYSQL_TIME expire;
- MySqlConnection::convertToDatabaseTime(lease->old_cltt_, lease->old_valid_lft_,
+ MySqlConnection::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_,
expire);
inbind[1].buffer_type = MYSQL_TYPE_TIMESTAMP;
inbind[1].buffer = reinterpret_cast<char*>(&expire);
// Drop to common update code
updateLeaseCommon(ctx, stindex, &bind[0], lease);
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
}
// Delete lease methods. Similar to other groups of methods, these comprise
inbind[0].is_unsigned = MLM_TRUE;
MYSQL_TIME expire;
- MySqlConnection::convertToDatabaseTime(lease->old_cltt_, lease->old_valid_lft_,
+ MySqlConnection::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_,
expire);
inbind[1].buffer_type = MYSQL_TYPE_TIMESTAMP;
inbind[1].buffer = reinterpret_cast<char*>(&expire);
inbind[0].length = &addr6_length;
MYSQL_TIME expire;
- MySqlConnection::convertToDatabaseTime(lease->old_cltt_, lease->old_valid_lft_,
+ MySqlConnection::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_,
expire);
inbind[1].buffer_type = MYSQL_TYPE_TIMESTAMP;
inbind[1].buffer = reinterpret_cast<char*>(&expire);
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The UPDATE query uses WHERE expire = ? to update the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and UPDATE.
+ /// enforcing no update on the lease between SELECT and UPDATE with
+ /// different expiration time.
virtual void updateLease4(const Lease4Ptr& lease4);
/// @brief Updates IPv6 lease.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The UPDATE query uses WHERE expire = ? to update the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and UPDATE.
+ /// enforcing no update on the lease between SELECT and UPDATE with
+ /// different expiration time.
virtual void updateLease6(const Lease6Ptr& lease6);
/// @brief Deletes an IPv4 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The DELETE query uses WHERE expire = ? to delete the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and DELETE.
+ /// enforcing no update on the lease between SELECT and DELETE with
+ /// different expiration time.
virtual bool deleteLease(const Lease4Ptr& lease);
/// @brief Deletes an IPv6 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The DELETE query uses WHERE expire = ? to delete the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and DELETE.
+ /// enforcing no update on the lease between SELECT and DELETE with
+ /// different expiration time.
virtual bool deleteLease(const Lease6Ptr& lease);
/// @brief Deletes all expired-reclaimed DHCPv4 leases.
subnet_id_, fqdn_fwd_,
fqdn_rev_, hostname_,
hwaddr, prefix_len_));
- // Update cltt_ and old_cltt_ explicitly.
+ // Update cltt_ and current_cltt_ explicitly.
result->cltt_ = cltt_;
- result->old_cltt_ = cltt_;
+ result->current_cltt_ = cltt_;
result->state_ = state;
ctx->exchange4_->createBindForSend(lease, bind_array);
auto result = addLeaseCommon(ctx, INSERT_LEASE4, bind_array);
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return (result);
}
auto result = addLeaseCommon(ctx, INSERT_LEASE6, bind_array);
- // Update lease lifetime with new values (allows update between the creation
+ // Update lease current expiration time (allows update between the creation
// of the Lease up to the point of insertion in the database).
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
return (result);
}
std::string addr4_str = boost::lexical_cast<std::string>(lease->addr_.toUint32());
bind_array.add(addr4_str);
- std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->old_cltt_,
- lease->old_valid_lft_);
+ std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_);
bind_array.add(expire_str);
// Drop to common update code
updateLeaseCommon(ctx, stindex, bind_array, lease);
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
}
void
std::string addr_str = lease->addr_.toText();
bind_array.add(addr_str);
- std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->old_cltt_,
- lease->old_valid_lft_);
+ std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_);
bind_array.add(expire_str);
// Drop to common update code
updateLeaseCommon(ctx, stindex, bind_array, lease);
- // Update lease lifetime with new values.
- lease->updateExistingLifetime();
+ // Update lease current expiration time.
+ lease->updateCurrentExpirationTime();
}
uint64_t
std::string addr4_str = boost::lexical_cast<std::string>(addr.toUint32());
bind_array.add(addr4_str);
- std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->old_cltt_,
- lease->old_valid_lft_);
+ std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_);
bind_array.add(expire_str);
auto affected_rows = deleteLeaseCommon(DELETE_LEASE4, bind_array);
std::string addr6_str = addr.toText();
bind_array.add(addr6_str);
- std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->old_cltt_,
- lease->old_valid_lft_);
+ std::string expire_str = PgSqlLeaseExchange::convertToDatabaseTime(lease->current_cltt_,
+ lease->current_valid_lft_);
bind_array.add(expire_str);
auto affected_rows = deleteLeaseCommon(DELETE_LEASE6, bind_array);
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The UPDATE query uses WHERE expire = ? to update the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and UPDATE.
+ /// enforcing no update on the lease between SELECT and UPDATE with
+ /// different expiration time.
virtual void updateLease4(const Lease4Ptr& lease4);
/// @brief Updates IPv6 lease.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The UPDATE query uses WHERE expire = ? to update the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and UPDATE.
+ /// enforcing no update on the lease between SELECT and UPDATE with
+ /// different expiration time.
virtual void updateLease6(const Lease6Ptr& lease6);
/// @brief Deletes an IPv4 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The DELETE query uses WHERE expire = ? to delete the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and DELETE.
+ /// enforcing no update on the lease between SELECT and DELETE with
+ /// different expiration time.
virtual bool deleteLease(const Lease4Ptr& lease);
/// @brief Deletes an IPv6 lease.
///
/// @return true if deletion was successful, false if no such lease exists.
///
- /// @note The old_cltt_ and old_valid_lft_ are used to ensure that only one
- /// thread or process performs an update or delete operation on the lease by
- /// matching these values with the expired data in the database.
+ /// @note The current_cltt_ and current_valid_lft_ are used to maximize the
+ /// chance that only one thread or process performs an update or delete
+ /// operation on the lease by matching these values with the expiration time
+ /// data in the database.
/// @note The DELETE query uses WHERE expire = ? to delete the lease only if
/// the value matches the one received on the SELECT query, effectively
- /// enforcing no update on the lease between SELECT and DELETE.
+ /// enforcing no update on the lease between SELECT and DELETE with
+ /// different expiration time.
virtual bool deleteLease(const Lease6Ptr& lease);
/// @brief Deletes all expired-reclaimed DHCPv4 leases.
// We verify the "time" change in case the lease returned to us
// by expectOneLease ever becomes a copy and not what is in the lease mgr.
--lease->cltt_;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
lease->addr_);
ASSERT_TRUE(from_mgr);
// We verify the "time" change in case the lease returned to us
// by expectOneLease ever becomes a copy and not what is in the lease mgr.
--lease->cltt_;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
lease->addr_);
ASSERT_TRUE(from_mgr);
lease->client_id_ = ClientIdPtr(new ClientId(vector<uint8_t>(8, 0x42)));
lease->valid_lft_ = 8677;
lease->cltt_ = 168256;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 23;
lease->fqdn_rev_ = true;
lease->fqdn_fwd_ = false;
new ClientId(vector<uint8_t>(8, 0x53)));
lease->valid_lft_ = 3677;
lease->cltt_ = 123456;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 73;
lease->fqdn_rev_ = true;
lease->fqdn_fwd_ = true;
lease->client_id_ = ClientIdPtr(new ClientId(vector<uint8_t>(8, 0x64)));
lease->valid_lft_ = 5412;
lease->cltt_ = 234567;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 73; // Same as lease 1
lease->fqdn_rev_ = false;
lease->fqdn_fwd_ = false;
// @TODO: test overflow conditions when code has been fixed.
lease->valid_lft_ = 7000;
lease->cltt_ = 234567;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 37;
lease->fqdn_rev_ = true;
lease->fqdn_fwd_ = true;
new ClientId(vector<uint8_t>(8, 0x53))); // Same as lease 1
lease->valid_lft_ = 7736;
lease->cltt_ = 222456;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 85;
lease->fqdn_rev_ = true;
lease->fqdn_fwd_ = true;
new ClientId(vector<uint8_t>(8, 0x53))); // Same as lease 1
lease->valid_lft_ = 7832;
lease->cltt_ = 227476;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 175;
lease->fqdn_rev_ = false;
lease->fqdn_fwd_ = false;
new ClientId(vector<uint8_t>(8, 0x53))); // Same as lease 1
lease->valid_lft_ = 1832;
lease->cltt_ = 627476;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 112;
lease->fqdn_rev_ = false;
lease->fqdn_fwd_ = true;
new ClientId(vector<uint8_t>(8, 0x77)));
lease->valid_lft_ = 7975;
lease->cltt_ = 213876;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 19;
lease->fqdn_rev_ = true;
lease->fqdn_fwd_ = true;
lease->preferred_lft_ = 900;
lease->valid_lft_ = 8677;
lease->cltt_ = 168256;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 23;
lease->fqdn_fwd_ = true;
lease->fqdn_rev_ = true;
lease->preferred_lft_ = 3600;
lease->valid_lft_ = 3677;
lease->cltt_ = 123456;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 73;
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
lease->preferred_lft_ = 1800;
lease->valid_lft_ = 5412;
lease->cltt_ = 234567;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 73; // Same as lease 1
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = false;
lease->preferred_lft_ = 7200;
lease->valid_lft_ = 7000;
lease->cltt_ = 234567;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 37;
lease->fqdn_fwd_ = true;
lease->fqdn_rev_ = false;
lease->preferred_lft_ = 4800;
lease->valid_lft_ = 7736;
lease->cltt_ = 222456;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 671;
lease->fqdn_fwd_ = true;
lease->fqdn_rev_ = true;
lease->preferred_lft_ = 5400;
lease->valid_lft_ = 7832;
lease->cltt_ = 227476;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 175;
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
lease->preferred_lft_ = 5400;
lease->valid_lft_ = 1832;
lease->cltt_ = 627476;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 112;
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
lease->preferred_lft_ = 5600;
lease->valid_lft_ = 7975;
lease->cltt_ = 213876;
- lease->updateExistingLifetime();
+ lease->updateCurrentExpirationTime();
lease->subnet_id_ = 19;
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
ASSERT_TRUE(lease->client_id_);
EXPECT_EQ("17:34:e2:ff:09:92:54", lease->client_id_->toText());
EXPECT_EQ(12345678, lease->cltt_);
- EXPECT_EQ(lease->cltt_, lease->old_cltt_);
+ EXPECT_EQ(lease->cltt_, lease->current_cltt_);
EXPECT_EQ(3600, lease->valid_lft_);
- EXPECT_EQ(lease->valid_lft_, lease->old_valid_lft_);
+ EXPECT_EQ(lease->valid_lft_, lease->current_valid_lft_);
EXPECT_TRUE(lease->fqdn_fwd_);
EXPECT_TRUE(lease->fqdn_rev_);
EXPECT_EQ("urania.example.org", lease->hostname_);
ASSERT_TRUE(lease->hwaddr_);
EXPECT_EQ("hwtype=1 08:00:2b:02:3f:4e", lease->hwaddr_->toText());
EXPECT_EQ(12345678, lease->cltt_);
- EXPECT_EQ(lease->cltt_, lease->old_cltt_);
+ EXPECT_EQ(lease->cltt_, lease->current_cltt_);
EXPECT_EQ(800, lease->valid_lft_);
- EXPECT_EQ(lease->valid_lft_, lease->old_valid_lft_);
+ EXPECT_EQ(lease->valid_lft_, lease->current_valid_lft_);
EXPECT_FALSE(lease->fqdn_fwd_);
EXPECT_FALSE(lease->fqdn_rev_);
EXPECT_EQ("urania.example.org", lease->hostname_);
ASSERT_TRUE(lease->hwaddr_);
EXPECT_EQ("hwtype=1 08:00:2b:02:3f:4e", lease->hwaddr_->toText());
EXPECT_EQ(12345678, lease->cltt_);
- EXPECT_EQ(lease->cltt_, lease->old_cltt_);
+ EXPECT_EQ(lease->cltt_, lease->current_cltt_);
EXPECT_EQ(600, lease->valid_lft_);
- EXPECT_EQ(lease->valid_lft_, lease->old_valid_lft_);
+ EXPECT_EQ(lease->valid_lft_, lease->current_valid_lft_);
EXPECT_FALSE(lease->fqdn_fwd_);
EXPECT_FALSE(lease->fqdn_rev_);
EXPECT_EQ("urania.example.org", lease->hostname_);