@@ -233,8 +233,10 @@ func (in *BQInserter) updateMetrics(err error) error {
233233 }
234234 // If ALL rows failed...
235235 if len (typedErr ) == in .pending {
236+ log .Printf ("InsertErr %v %v\n " , err , typedErr .Error ()) // Log the first RowInsertionError detail
237+ // Backend failure counts failed RPCs.
236238 metrics .BackendFailureCount .WithLabelValues (
237- in .TableBase (), "failed insert" ).Inc ()
239+ in .TableBase (), "putmulti failed insert" ).Inc ()
238240 in .failures ++
239241 }
240242
@@ -243,43 +245,46 @@ func (in *BQInserter) updateMetrics(err error) error {
243245 // Handle each error individually.
244246 for i , rowError := range typedErr {
245247 // These are rowInsertionErrors
246- log .Printf ("Insert error: %d %s on %s\n " , i , rowError .Error (), in .FullTableName ())
248+ log .Printf ("InsertErr %d %s on %s\n " , i , rowError .Error (), in .FullTableName ())
247249 }
248250 } else if len (typedErr ) > 0 {
249251 // Otherwise, just log the first RowInsertionError detail
250- log .Printf ("%d insert errors: %v %s on %s\n " , len (typedErr ), err , typedErr [0 ].Error (), in .FullTableName ())
252+ log .Printf ("InsertErr (%d) %v %s on %s\n " , len (typedErr ), err , typedErr [0 ].Error (), in .FullTableName ())
251253 }
252254
255+ // ErrorCount counts failed rows.
253256 metrics .ErrorCount .WithLabelValues (
254- in .TableBase (), "PutMultiError" , "insert row error" ).
257+ in .TableBase (), "PutMultiError" , "putmulti error" ).
255258 Add (float64 (len (typedErr )))
256259 in .inserted -= len (typedErr )
257260 in .badRows += len (typedErr )
258261 err = nil
259262 case * url.Error :
260- log .Printf ("Insert url.Error: %v on %s" , typedErr , in .FullTableName ())
263+ log .Printf ("InsertErr url.Error: %v on %s" , typedErr , in .FullTableName ())
261264 metrics .BackendFailureCount .WithLabelValues (
262- in .TableBase (), "failed insert" ).Inc ()
265+ in .TableBase (), "url failed insert" ).Inc ()
263266 metrics .ErrorCount .WithLabelValues (
264- in .TableBase (), "url.Error" , "UNHANDLED insert error" ).Inc ()
267+ in .TableBase (), "url.Error" , "UNHANDLED url insert error" ).Inc ()
265268 // TODO - Conservative, but possibly not correct.
266269 // This at least preserves the count invariance.
267270 in .inserted -= in .pending
268271 in .badRows += in .pending
269272 err = nil
270273 case * googleapi.Error :
271274 // TODO add special handling for Quota Exceeded
272- log .Printf ("Insert error: %v on %s" , typedErr , in .FullTableName ())
275+ log .Printf ("InsertErr %v on %s" , typedErr , in .FullTableName ())
273276 if strings .Contains (err .Error (), "Quota exceeded:" ) {
274277 metrics .BackendFailureCount .WithLabelValues (
275278 in .TableBase (), "quota exceeded" ).Inc ()
276279 metrics .ErrorCount .WithLabelValues (
277- in .TableBase (), "googleapi.Error" , "Insert: Quota Exceeded" ).Inc ()
280+ in .TableBase (), "googleapi.Error" , "Insert: Quota Exceeded" ).
281+ Add (float64 (in .pending ))
278282 } else {
279283 metrics .BackendFailureCount .WithLabelValues (
280- in .TableBase (), "failed insert" ).Inc ()
284+ in .TableBase (), "googleapi failed insert" ).Inc ()
281285 metrics .ErrorCount .WithLabelValues (
282- in .TableBase (), "googleapi.Error" , "UNHANDLED insert error" ).Inc ()
286+ in .TableBase (), "googleapi.Error" , "UNHANDLED googleapi error" ).
287+ Add (float64 (in .pending ))
283288 }
284289 // TODO - Conservative, but possibly not correct.
285290 // This at least preserves the count invariance.
@@ -289,14 +294,15 @@ func (in *BQInserter) updateMetrics(err error) error {
289294
290295 default :
291296 // With Elem(), this was causing panics.
292- log .Printf ("Unhandled %v: %v on %s\n " , reflect .TypeOf (typedErr ),
297+ log .Printf ("InsertErr ( Unhandled) %v: %v on %s\n " , reflect .TypeOf (typedErr ),
293298 typedErr , in .FullTableName ())
294299 metrics .BackendFailureCount .WithLabelValues (
295300 in .TableBase (), "failed insert" ).Inc ()
296- metrics .ErrorCount .WithLabelValues (
297- in .TableBase (), "unknown" , "UNHANDLED insert error" ).Inc ()
298- // TODO - Conservative, but possibly not correct.
301+ // TODO - This accounting is conservative, but possibly overestimates failed rows.
299302 // This at least preserves the count invariance.
303+ metrics .ErrorCount .WithLabelValues (
304+ in .TableBase (), "unknown" , "UNHANDLED insert error" ).
305+ Add (float64 (in .pending ))
300306 in .inserted -= in .pending
301307 in .badRows += in .pending
302308 err = nil
@@ -357,6 +363,7 @@ func (in *BQInserter) Flush() error {
357363// Commit implements row.Sink.
358364// NOTE: the label is ignored, and the TableBase is used instead.
359365func (in * BQInserter ) Commit (rows []interface {}, label string ) error {
366+ // TODO - this causes large memory and large number of goroutines.
360367 in .acquire ()
361368 defer in .release ()
362369 return in .flushSlice (rows )
0 commit comments