-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprepare_src
More file actions
executable file
·59 lines (51 loc) · 1.47 KB
/
prepare_src
File metadata and controls
executable file
·59 lines (51 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
good=false
try=0
while [ $try -lt 5 ]; do
((try++))
if [ $try -ne 1 ]; then
echo "Waiting to start attempt $try"
sleep 900
fi
echo "Starting attempt $try"
# Because of how LDLite holds state and the streaming endpoint work
# normal LDLite retries don't work with source records.
# This is a temporary hack to add retries to the source records until
# LDLite can be made to retry them properly.
$(uv python find) src_download.py > ../logs/`date "+%Y%m%d-%H%M"`.$try.src.log 2>&1
ok=$?
if [ $ok -ne 0 ]; then
echo "Errored running ldlite... retrying"
continue
fi
echo "Checking attempt"
exists=$(psql -v "ON_ERROR_STOP=1" -AXqt < src_records_exists.sql)
ok=$?
if [ $ok -ne 0 ]; then
echo "Errored checking for existence... exiting"
exit $ok
fi
if [ $exists -eq 0 ]; then
echo "Table does not exist... retrying"
continue
fi
count=$(psql -v "ON_ERROR_STOP=1" -AXqt < src_records_full.sql)
ok=$?
if [ $ok -ne 0 ]; then
echo "Errored checking for count... exiting"
exit $ok
fi
if [ $count -lt 5000000 ]; then
echo "Only found $count rows... retrying"
continue
fi
echo "Attempt $try was good!"
good=true
break
done
if [ "$good" = false ]; then
echo "Exhausted attempts... exiting"
exit 1
fi
echo "Preparing for ldpmarc"
/usr/bin/psql < alter_src_rec.sql > ../logs/`date "+%Y%m%d-%H%M"`.alter_src.log 2>&1