gpload may fail during table metadata discovery when loading data into a table that contains a sequence-backed column, such as a column defined using DEFAULT nextval(...).
The failure occurs before any data is loaded and gpload terminates with an error similar to:
Traceback (most recent call last):
File "/usr/local/greenplum-db-7.x.x/bin/gpload.py", line XXXX, in run
self.run2()
File "/usr/local/greenplum-db-7.x.x/bin/gpload.py", line XXXX, in run2
self.read_table_metadata()
File "/usr/local/greenplum-db-7.x.x/bin/gpload.py", line XXXX, in read_table_metadata
i = [name,ct,None, has_seq_bool]
UnboundLocalError: local variable 'has_seq_bool' referenced before assignment
This issue is caused by a defect in the gpload metadata processing logic introduced in the GPDB 7.x code path.
In gpload.py, the sequence detection logic contains an incorrect variable assignment:
has_seq = row['has_sequence']
if has_seq == str('f') or has_seq == False:
has_seq_bool = False
if has_seq == str('t') or has_seq == True:
has_sql_bool = True
i = [name,ct,None, has_seq_bool]When a sequence-backed column is detected (has_seq=True), the code assigns a value to has_sql_bool, but later references has_seq_bool, which was never initialized. This results in the observed UnboundLocalError.
Resolution
Engineering has fixed this issue and the fix is planned for inclusion in Greenplum 7.8.3.
Customers should upgrade to a release containing the fix once it becomes available.
Workaround
Customer can modify gpload.py until the fix is released by following below steps:
cp /usr/local/greenplum-db-clients-<version>/bin/gpload.py /usr/local/greenplum-db-clients-<version>/bin/gpload.py.bakvi /usr/local/greenplum-db-clients-<version>/bin/gpload.pyif has_seq == str('t') or has_seq==True:
has_sql_bool = Trueif has_seq == str('t') or has_seq==True:
has_seq_bool = Truegpload job.The workaround was validated in a GPDB 7.x and allowed the load to complete successfully.