When running GPLOAD with "TRUNCATE:TRUE" and doing INSERT, "TRUNCATE" could not rollback
search cancel

When running GPLOAD with "TRUNCATE:TRUE" and doing INSERT, "TRUNCATE" could not rollback

book

Article ID: 296885

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

From the below scenario, we can see the "TRUNCATE" could not be rolled back:
  • For example we have below gpload config:
$ vi gpload_foo.yaml
VERSION: 1.0.0.1
GPLOAD:
INPUT:
- SOURCE:
FILE:
- /home/gpadmin/foo.csv
- FORMAT: csv
- HEADER: true
- LOG_ERRORS: true
- ERROR_LIMIT: 20
OUTPUT:
- TABLE: public.foo
- MODE: insert
PRELOAD:
- TRUNCATE: true
- REUSE_TABLES: true 
  • Create a test table and insert some data:
$ psql -c "CREATE TABLE public.foo (a int, b text) DISTRIBUTED BY (a);"

$ psql -c "insert into public.foo values (1,'b');"

$ psql -c "select count(*) from public.foo;"
count
-------
1
(1 row) 
  • After that, touch a file and put into some wrong data:
8,"a"
9,"a"
10,"a"
"a","a"
"a","a"
"a","a"
"a","a"
  • Thus, we can see gpload failed but the "TRUNCATE" did not get rolled back:
$ gpload -f gpload_foo.yaml

$ psql -c "select count(*) from public.foo;"
count
-------
0


Environment

Greenplum 6.23

Resolution

Fix

The permanent fix is available in 6.25.2 and above.

Workaround

Current workaround is to modify the the file $GPHOME/bin/gpload.py.
There are two lines of this:

if not self.options.no_auto_trans and not method=='insert':

Modified both to:

if not self.options.no_auto_trans:

Then check that it works.

Note: This is just a temporary workaround, backup the file before editing.