title: AWK returns duplicated record when traversing an array
body: <p>I'm agregating data from a 15 M records (file XXX) into arrays with awk. When ENDing the awk, I print every aggregated record (aprox, 2,25 M), but, from time to time, it returns 1 duplicated record. The code (simplified) is like this:</p>
  
  <pre><code>awk '{
    id=substr($0,18,25)
    date=substr($0,131,14)
    field_#=substr($0,##,###)               --&gt; Many fields
    key=id "," date
    array_#[key]=array_#[key] + field_#     --&gt; 4 arrays, some using 3 fields
  }END{
    for key in array_1{
      print(array_1[key] "," array_2[key] "," array_3[key] "," array_4[key])
    }
  }' XXX
  </code></pre>
  
  <p>Is there something in the code that can lead to duplicated records?
  Related to this, when this hapens, it raises a "cannot fork" memory error message, as it is using 12 GB out of 16GB that has the machine. Is there any reason that can lead to that fault?</p>
  
  <p>I've already checked that there isn't any special characters in the file, as they could lead to "fake" duplicated keys.</p>
  
  ###### DATA
  
  <pre><code>INPUT
  #...### IDENTIFIER   ####...### VOL_UP    VOL_DOWN  VOL_TOTAL ###...#### YYYYMMDDHHMISS #####
  #...### 9876123      ####...### 123456    665204500 665327956 ###...#### 20180529020103 #####
  #...### 7854954      ####...### 654       456121    456775    ###...#### 20180529102501 #####
  #...### 9876123      ####...### 105251    58044518  58149769  ###...#### 20180529020103 #####
  
  OUTPUT
  #...### 9876123      ####...### 228707    723249018 723477725 ###...#### 20180529020103 #####
  #...### 7854954      ####...### 654       456121    456775    ###...#### 20180529102501 #####
  </code></pre>