Skip to content

Commit 625eb81

Browse files
committed
add 'aborted' as a retryable error
1 parent e2f5954 commit 625eb81

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

infra/bigquery-export/src/firestore.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Firestore } from '@google-cloud/firestore'
22
import { BigQueryExport } from './bigquery.js'
33

44
export class FirestoreBatch {
5-
constructor () {
5+
constructor() {
66
this.firestore = new Firestore({
77
gaxOptions: {
88
grpc: {
@@ -29,7 +29,7 @@ export class FirestoreBatch {
2929
}
3030

3131
// Memory monitoring utility
32-
logMemoryUsage (operation = '') {
32+
logMemoryUsage(operation = '') {
3333
const used = process.memoryUsage()
3434
const memoryInfo = {
3535
rss: Math.round(used.rss / 1024 / 1024 * 100) / 100,
@@ -50,7 +50,7 @@ export class FirestoreBatch {
5050
}
5151

5252
// Enhanced reset with memory cleanup
53-
reset () {
53+
reset() {
5454
this.processedDocs = 0
5555
this.totalDocs = 0
5656

@@ -73,7 +73,7 @@ export class FirestoreBatch {
7373
this.logMemoryUsage('after reset')
7474
}
7575

76-
createBulkWriter (operation) {
76+
createBulkWriter(operation) {
7777
const bulkWriter = this.firestore.bulkWriter()
7878

7979
bulkWriter.maxBatchSize = 500 // Reduce batch size for memory efficiency
@@ -84,7 +84,7 @@ export class FirestoreBatch {
8484
console.warn(`${operation} operation failed${progressInfo}:`, error.message)
8585

8686
// Retry on transient errors, fail on permanent ones
87-
const retryableErrors = ['deadline-exceeded', 'unavailable', 'resource-exhausted']
87+
const retryableErrors = ['deadline-exceeded', 'unavailable', 'resource-exhausted', 'aborted']
8888
return retryableErrors.includes(error.code)
8989
})
9090

@@ -107,7 +107,7 @@ export class FirestoreBatch {
107107
return bulkWriter
108108
}
109109

110-
buildQuery (collectionRef) {
110+
buildQuery(collectionRef) {
111111
const queryMap = {
112112
report: () => {
113113
console.info(`Deleting documents from ${this.collectionName} for date ${this.date}`)
@@ -127,7 +127,7 @@ export class FirestoreBatch {
127127
return queryBuilder()
128128
}
129129

130-
async getDocumentCount (query) {
130+
async getDocumentCount(query) {
131131
try {
132132
const countSnapshot = await query.count().get()
133133
return countSnapshot.data().count
@@ -137,7 +137,7 @@ export class FirestoreBatch {
137137
}
138138
}
139139

140-
async batchDelete () {
140+
async batchDelete() {
141141
console.info('Starting batch deletion...')
142142
const startTime = Date.now()
143143
this.reset()
@@ -188,7 +188,7 @@ export class FirestoreBatch {
188188
console.info(`Deletion complete. Total docs deleted: ${this.processedDocs}. Time: ${duration} seconds`)
189189
}
190190

191-
async streamFromBigQuery (rowStream) {
191+
async streamFromBigQuery(rowStream) {
192192
console.info('Starting BigQuery to Firestore transfer...')
193193
const startTime = Date.now()
194194
this.reset()
@@ -239,7 +239,7 @@ export class FirestoreBatch {
239239
console.info(`Transfer to ${this.collectionName} complete. Total rows processed: ${this.processedDocs}. Time: ${duration} seconds`)
240240
}
241241

242-
async export (query, exportConfig) {
242+
async export(query, exportConfig) {
243243
console.log(`Starting export to ${exportConfig.collection}...`)
244244
this.logMemoryUsage('at start')
245245

0 commit comments

Comments
 (0)