Closed Bug 596660 Opened 14 years ago Closed 14 years ago

reports.uptime appearing sometimes as null

Categories

(Socorro :: General, task, P2)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ryansnyder, Assigned: rhelmer)

Details

Attachments

(1 file, 1 obsolete file)

Some reports that are being fed into Postgres from hBase are being inserted with a default uptime value of null, instead of a default value of 0.  Uptime should be inserted with a default value of 0.
This is the root cause of bug 596637
Assignee: nobody → robert
Target Milestone: --- → 1.8
@Assigning to rhelmer

This is the root cause of Bug#596637. We have bullet-proofed the cron so this isn't an issue for us.

We should go through and compare crash properties like uptime with the Postgres DB Schema and default values the same way that PG did.

Example:
reports table uptime default value 0

hbase/db feeder code should check for null or empty string and make this a 0 before inserting into the reports table.
I am pretty sure this is happening because StartupTime is not always sent by the client, and in this case an exception will be thrown here and uptime sent to None:

http://code.google.com/p/socorro/source/browse/trunk/socorro/processor/daemon_proc.py#886

The processor used in the previous release did this differently, using a method called "getJsonOrWarn()" to fall back to the value of timestampTime
 if StartupTime is unset:

http://code.google.com/p/socorro/source/browse/tags/releases/1.7.2_20100715/socorro/processor/processor.py#753

I hacked up daemon_proc.py a little to read a JSON file we got from the wild with no StartupTime, and the JSON that daemon_proc.py generates for HBase does have "'uptime':None" in it. From reading dbfeeder, I am pretty sure that this just inserts a NULL into PostgreSQL.

I am still getting my dev environment set up, so I'll have a go at a patch once I can test it end-to-end. I think making the processor a little more testable adding unit tests here would make these kinds of changes easier in the future too.
This does the bare minimum to prevent another occurrence of bug 596637. The changes I propose in comment 3 are nice to have but should not be release-blocking. Maybe best to spin out separate bugs ("unit tests for processor", "uptime column should be NOT NULL in reports table").

Currently testing this, Lars let me know if you agree with the above and I'll ask for review once testing and any further changes are done.
Attachment #479837 - Flags: feedback?(lars)
Attachment #479837 - Attachment is obsolete: true
Attachment #479837 - Flags: feedback?(lars)
This is the same as attachment 479837 [details] [diff] [review] except it sets uptime to 0 instead of date_processed (which was not correct anyway, I had meant to do max(0,processed_time - startupTime) which is what the old code ended up doing in a roundabout way, but hadn't done it yet) and the log message I added has been removed.

The more I look at it I don't think it would ever not be 0 in this case if crash_time is not supplied by the client, due to the max(0,...):
http://code.google.com/p/socorro/source/browse/tags/releases/1.7.2_20100715/socorro/processor/processor.py#765

In any case, I think this makes more sense because we don't know why the exception was thrown, it could have been a problem in client_crash_time or client_startup_time so we should cover our bases.
Attachment #479847 - Flags: feedback?(lars)
Comment on attachment 479847 [details] [diff] [review]
set uptime to 0 instead of None

looks fine to me.
Attachment #479847 - Flags: feedback?(lars) → feedback+
Status: NEW → ASSIGNED
Priority: -- → P3
Priority: P3 → P2
Finally got around to testing this locally now that I have everything set up; inserting a crash with missing StartupTime causes the update column to be set to 0 rather than null with this patch.

Committed revision 2627.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Component: Socorro → General
Product: Webtools → Socorro
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: