1

Does db2 check for file locks when running the db2 import/export command?

I have 2 processes, one runs an export to ixf, and another process that imports the ixf. Both run multiple times a day, the export process is variable time and I don't want to import the ixf if it is currently being written to.

coder
  • 8,346
  • 16
  • 39
  • 53
linuxnovice
  • 55
  • 1
  • 3

2 Answers2

0

This can be implementation detail specific, so consider a safer design to handle the starting of the import only after successful completion of export, possibly by smarter scheduling or different scripting.

If you start a Db2 import from IXF, and then start a Db2 export to the same IXF, then currently supported versions of Db2-LUW clients should fail the export with SQL3001c (i/O error opening the output file) for local file systems.

If you start an export to IXF, and then start an import from that same IXF before the export has completed, then currently supported versions of Db2-LUW clients should fail the import again with SQL3030C (i/o error opening the input file) at least for local file systems.

However, behaviour can vary with operating-system, the file-system hosting the input/output files, file-system mount options etc, and of course bugs are unavoidable. For those reasons, consider a more robust design.

mao
  • 11,321
  • 2
  • 13
  • 29
  • Would db2 throw an error on import if it was trying to import a csv file that was being copied from another server? Do you recommend any books to read for db2 and file read/write collisions – linuxnovice Jul 23 '18 at 14:46
  • You should not use comments for follow up questions. I don't know any Db2 books that would give implementation details about file-open-modes per comand. Some network copy tools use a temporary file name and rename only when all the data is successfully copied. Scripts can also wait for a network-copy to complete if they are able to pull the content, and only process the file on zero return code. Scripts that push content to a target server could push a flag file on successful copy, and other scripts that run on the target could act only on the presence of a flag file. – mao Jul 23 '18 at 15:26
0

I think that depends on the isolation level used in the query of the export, and the locks acquired for the import. If the import has an insert type, the locks are on the rows. If the import has a replace type, the lock will be at table level.

However, I do not have any references to support the previous paragraph.

AngocA
  • 7,655
  • 6
  • 39
  • 55