Icon

Parallel writing to Files

Annotations and comments
  • ISSUE with CSV Writer Despite beign executed (state green), despite lock files which prevent inteerference, despite implicit wait of two seconds ... thee CSV Writer does not seem to finished! Result: Corrupt Table Structure !!! IMPORTANT !!! There are a few isssue with the CSV Writer as well as the List Files/Folders Node Using Wait node to wait for file deletion is buggy. See: https://forum.knime.com/t/wait-node-wait-for-file-deletion-stuck-in-loop/83324 Using List FIles/Folders is buggy too. See: https://forum.knime.com/t/list-files-folders-should-return-no-result-but-fails-instead/83377
  • Preamble - "With great power comes great responsibility" KNIME offers a vast array of options. Its "low to no code" approach makes problem-solving accessible and democratizes its use. However, with that "power" also comes responsibility. The ease of use in KNIME can create a false sense of security because "it just works." Intention KNIME users might simply go with the flow of "it just works," without verifying results when advancing to more sophisticated solutions. Alternatively, while attempting to fully leverage KNIME's parallel processing capabilities, users might encounter data consistency issues, as demonstrated here. Purpose - Scenario Given the situation of scraping a complte website. Some URLs might not be present in the XML-Sitemap or no XML-Sitemap exists et all. If scraping each page takes five seconds and assuming a website has 10k pages, scraping it with one process, it would take: 50.000 seconds = 833 Minutes = circa 14 hours For ten parallel processes that time would be reduced to a little more than one hour! In order to scrape all URLs in the most efficient (parallel) way, it must be ensured that each thread (chunk) identifies new URLs but no parallel process is scraping already identified URLs. That requires one file all parallel processes can access to write newly identifies URLs into, "claiming scrape-authority".
  • Python Works Using a Python node to write to the CSV File creates a uniform data
  • Showcase Intention Display issue, intended to fail Expected Result Should create uniform table with three columns Problem File (table type) either gets corrupted or data (CSV) gets so too since chunks interfere with each other.
  • Writing to table in parallel can corrupt table file. Reading a corrupt table can result in an error like: Execute failed: invalid entry size (expected 114508917 but got 76869 bytes)
  • Add 10k rows
  • test-parallel-python.csv
  • test-parallel-column-to-one-cell.csv
  • test-parallel-default.csv
  • test.csv
  • Delete test.csv
  • Delete test.table
  • Define Temp Prefix
  • +1 and enforce Int Type
  • First 15 rows
  • Row Index
  • test.table Does NOT fail if schema has changed
  • Interrupt upon Schema change
  • Append to test-parallel.csv
  • context.workflow.absolute-path
  • Console Logger
  • Set Lock Files for Chunk
  • Remove all Columns
  • Workflow Aabsolue path
  • file.separator and osgi.os
  • TOP No Lock File of current Chunk
  • Get all lock files of all Chunks
  • Get lock file of current Chunk
  • Loop until all Lock Files got deteled
  • Brute force execution to bypass bugs related to Files/folder Nodes
  • Remove Lock File of current Chunk
  • Keep if Lock File still exists
  • TOP Lock File of current Chunk
  • Oldes Lock file to top (first in, first out)
  • TOP Lock Files to wait for BOTTOM Current and all past Lock files
  • Loop until Lisst Files/Folders fails
  • Chunk Count
  • 2 Sec. delay
  • Append to test.csv
  • Fast namp to get IP and open Ports
  • Do NOT fail if schema has changed
  • Initialize empty test.table

Nodes

Extensions

Links