diff --git a/internal/geonames/geonames.go b/internal/geonames/geonames.go index f184425..ae1c9c8 100644 --- a/internal/geonames/geonames.go +++ b/internal/geonames/geonames.go @@ -339,6 +339,8 @@ func GetGeonameCountry(ctx context.Context, country string) ([]Geoname, error) { u := fmt.Sprintf("http://download.geonames.org/export/zip/%s.zip", country) resp, err = pester.Get(u) if err != nil { + // Add re-try three times after failing first time + // This reduces the risk when network is lagy, we still have chance to re-try. for i := 0; i < 3; i++ { resp, err = pester.Get(u) if err == nil { diff --git a/internal/schema/migrations.go b/internal/schema/migrations.go index bab4c17..2ec3bec 100644 --- a/internal/schema/migrations.go +++ b/internal/schema/migrations.go @@ -293,7 +293,7 @@ func migrationList(ctx context.Context, db *sqlx.DB, log *log.Logger, isUnittest return errors.WithStack(err) } //fmt.Println("Geoname records: ", len(v)) - + // Max argument values of Postgres is about 54460. So the batch size for bulk insert is selected 4500*12 (ncol) batch := 4500 n := len(v) / batch