Skip to content

ImportTask never closes its LDIFImportConfig when the import fails #1026

Description

@maximthomas

What happens

ImportTask.runTask() calls importConfig.close() after the outer try/finally (

), so it runs only when the method falls through on success. Every error return — disable failed (:650), lock not acquired (:661, :669), importLDIF threw (:690, :697), lock not released (:709, :717), re-enable failed (:747) — bypasses it.

LDIFImportConfig.close() is what closes the LDIF reader and the rejected-entries and skipped-entries writers the task opened at :594-620. On a failed import they stay open and unflushed, and importConfig is a field that the next run of the task overwrites, so nothing else ever closes them.

Consequence

  • The rejects file — the artefact an operator reads after a failed import — can be missing its buffered tail.
  • File handles leak per failed import for the life of the server.
  • On Windows the open handle blocks a subsequent run of the same task with ds-task-import-reject-file pointing at the same path.

Fix

Move importConfig.close() into the outer finally (its own try, before the listener notification), leaving the returns where they are.

Pre-existing, unchanged by #969; found while reviewing it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtasksServer administrative tasks: import, export, backup, restore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions