TechnitiumSoftware/DnsServer · error · DnsServerException
Cannot set records. Please try again.
Error message
Cannot set records. Please try again.
What it means
Thrown by PrimarySubDomainZone.SetRecords() when TrySetRecords(type, records, out deletedRecords) returns false. TrySetRecords performs the actual atomic swap into the per-type _entries store; a false return indicates the operation could not be applied (typically a concurrency/contention failure on the underlying store, since a type/value mismatch would have been caught earlier). The message 'Please try again' signals a transient retry-eligible condition. DnsServerException, catchable.
Source
Thrown at DnsServerCore/Dns/Zones/PrimarySubDomainZone.cs:97
case DnsResourceRecordType.SOA:
throw new InvalidOperationException("Cannot set SOA record on sub domain.");
case DnsResourceRecordType.DNSKEY:
case DnsResourceRecordType.RRSIG:
case DnsResourceRecordType.NSEC:
case DnsResourceRecordType.NSEC3PARAM:
case DnsResourceRecordType.NSEC3:
throw new InvalidOperationException("Cannot set DNSSEC records.");
case DnsResourceRecordType.FWD:
throw new DnsServerException("The record type is not supported by primary zones.");
default:
if (records[0].OriginalTtlValue > _primaryZone.GetZoneSoaExpire())
throw new DnsServerException("Cannot set records: TTL cannot be greater than SOA EXPIRE.");
if (!TrySetRecords(type, records, out IReadOnlyList<DnsResourceRecord> deletedRecords))
throw new DnsServerException("Cannot set records. Please try again.");
_primaryZone.CommitAndIncrementSerial(deletedRecords, records);
if (_primaryZone.DnssecStatus != AuthZoneDnssecStatus.Unsigned)
_primaryZone.UpdateDnssecRecordsFor(this, type);
_primaryZone.TriggerNotify();
break;
}
}
public override bool AddRecord(DnsResourceRecord record)
{
if (_primaryZone.DnssecStatus != AuthZoneDnssecStatus.Unsigned)
{
switch (record.Type)
{
case DnsResourceRecordType.ANAME:View on GitHub (pinned to d0484b6c1e)
Solutions
- Retry the SetRecords call after a short backoff (the message explicitly invites retry).
- Serialize writes to a given zone (one writer at a time) to avoid the contention that causes TrySetRecords to fail.
- If it persists, re-query the zone state and rebuild the record set before retrying, in case the conflict changed the stored data.
Example fix
// before
subZone.SetRecords(type, records);
// after
for (int attempt = 0; ; attempt++)
{
try { subZone.SetRecords(type, records); break; }
catch (DnsServerException ex) when (ex.Message.Contains("Please try again") && attempt < 5)
{
System.Threading.Thread.Sleep(100 * (attempt + 1));
}
} Defensive patterns
Strategy: retry
Validate before calling
// No pure-validation guard exists; this is a transient TrySetRecords failure.
// Pre-check writer contention: avoid concurrent SetRecords on the same zone.
using (await _zoneWriteLock.LockAsync())
zone.SetRecords(type, records); Try / catch
for (int i = 0; i < 5; i++)
{
try { zone.SetRecords(type, records); return; }
catch (DnsServerException ex) when (ex.Message.Contains("Please try again")) { await System.Threading.Tasks.Task.Delay(100 * (i + 1)); }
} Prevention
- Serialize writes per zone (lock or queue) so TrySetRecords does not contend.
- Treat 'Please try again' as retry-eligible with bounded exponential backoff.
- Limit import parallelism to one writer per zone.
When it happens
Trigger: subZone.SetRecords(type, records) losing a compare-exchange / lock race inside TrySetRecords — most often under concurrent writers (parallel imports, simultaneous API calls, zone replication + edit at once).
Common situations: Bulk import with high parallelism; two admin sessions editing the same zone; replication/notify firing while a SetRecords is in flight.
Related errors
- The record type is not supported by DNSSEC signed primary zo
- Cannot set records: disabling records in a signed zones is n
- The record type is not supported by primary zones.
- Cannot set records: TTL cannot be greater than SOA EXPIRE.
- Cannot add record: disabling records in a signed zones is no
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/92c2e7f3b8d3dfe0.
Report an issue: GitHub.