{"record":{"id":"63c7eaddf5c8f369","repo":"duplicati/duplicati","slug":"unable-to-add-change-journal-entry","errorCode":null,"errorMessage":"Unable to add change journal entry","messagePattern":"Unable to add change journal entry","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Duplicati/Library/Main/Database/Local/LocalBackupDatabase.cs","lineNumber":1975,"sourceCode":"                        )\n                        VALUES (\n                            @FilesetId,\n                            @VolumeName,\n                            @JournalId,\n                            @NextUsn,\n                            @ConfigHash\n                        );\n                    \")\n                        .SetParameterValue(\"@FilesetId\", m_filesetId)\n                        .SetParameterValue(\"@VolumeName\", entry.Volume)\n                        .SetParameterValue(\"@JournalId\", entry.JournalId)\n                        .SetParameterValue(\"@NextUsn\", entry.NextUsn)\n                        .SetParameterValue(\"@ConfigHash\", entry.ConfigHash)\n                        .ExecuteNonQueryAsync(token) // Not logging, as we log the whole operation\n                        .ConfigureAwait(false);\n\n                    if (c != 1)\n                        throw new Exception(\"Unable to add change journal entry\");\n                }\n\n            await m_rtr.CommitAsync(token: token).ConfigureAwait(false);\n        }\n\n        /// <summary>\n        /// Adds NTFS change journal data for file set and volume.\n        /// </summary>\n        /// <param name=\"data\">Data to add.</param>\n        /// <param name=\"fileSetId\">Existing file set to update.</param>\n        /// <param name=\"token\">The cancellation token to cancel the operation.</param>\n        /// <returns>A task that completes when the data is added.</returns>\n        public async Task UpdateChangeJournalDataAsync(IEnumerable<Interface.USNJournalDataEntry> data, long fileSetId, CancellationToken token)\n        {\n            using (new Logging.Timer(LOGTAG, \"UpdateChangeJournalData\", \"Updating USN entries\"))\n                foreach (var entry in data)\n                {\n                    await using var cmd = m_connection.CreateCommand();","sourceCodeStart":1957,"sourceCodeEnd":1993,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/Duplicati/Library/Main/Database/Local/LocalBackupDatabase.cs#L1957-L1993","documentation":"Generic Exception in CreateChangeJournalDataAsync: the INSERT into ChangeJournalData (NTFS USN change-journal data per fileset/volume) returned != 1 affected row for an entry. Each iteration inserts one row, so a count other than 1 signals a constraint violation, a race, or a schema issue with that journal entry.","triggerScenarios":"Call CreateChangeJournalDataAsync(data) where one entry's INSERT into ChangeJournalData returns 0 or >1 rows (e.g. a UNIQUE(FilesetID,VolumeName) constraint blocks it, or a concurrent insert already added the row).","commonSituations":"Duplicate volume entries in the same fileset; UNIQUE constraint on (FilesetID, VolumeName) already satisfied; concurrent backup writing the same journal data; schema/migration change; interrupted prior write.","solutions":["Deduplicate the USNJournalDataEntry collection by VolumeName per fileset before inserting.","Serialize operations writing change-journal data for the same fileset.","Run database repair to reconcile ChangeJournalData.","If a duplicate entry is benign for your workflow, filter it out upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Deduplicate entries by VolumeName before calling CreateChangeJournalDataAsync:\nvar distinct = data.GroupBy(e => e.Volume).Select(g => g.First());\nawait db.CreateChangeJournalDataAsync(distinct, token);","typeGuard":null,"tryCatchPattern":"try { await db.CreateChangeJournalDataAsync(data, token); }\ncatch (Exception ex) when (ex.Message.Contains(\"Unable to add change journal entry\"))\n{ Log.Error(\"ChangeJournal insert conflict; deduplicate per-volume and serialize writers.\"); throw; }","preventionTips":["Provide at most one USN entry per (FilesetID, VolumeName).","Serialize backup operations that write NTFS change-journal data."],"tags":["database","sqlite","data-integrity","ntfs","journal"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}