Bug 28063

Summary: [GTK] LayoutTests/http/tests/appcache/max-size.html fails
Product: WebKit Reporter: Martin Robinson <mrobinson>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: jmalonzo, laszlo.gombos
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Vacuum after pragma
none
Re-order the operations necessary for setting the maximum app cache size
none
Patch with more helpful Changelog entries
none
Patch with more helpful Changelog entries eric: review-

Description Martin Robinson 2009-08-07 00:06:45 PDT
WebKit does not appear to be respecting the application cache size.
Comment 1 Martin Robinson 2009-08-07 00:20:49 PDT
From WebKit/gtk/webkit/webkitapplicationcache.cpp:
    WebCore::cacheStorage().empty();
    WebCore::cacheStorage().vacuumDatabaseFile();
    WebCore::cacheStorage().setMaximumSize(size);

Documentation at http://www.sqlite.org/pragma.html seems to indicate that the vacuum should happen after setting the size though.
Comment 2 Martin Robinson 2009-08-07 00:24:24 PDT
Created attachment 34254 [details]
Vacuum after pragma

Patch which modifies the order of operations in the GTK+ port. If this is a true bug, other ports will likely need to be modified.
Comment 3 Martin Robinson 2009-08-07 20:02:00 PDT
For reference: this was originally failing for me on an Ubuntu Jaunty machine (sqlite 3.6.10-1ubuntu0.2) on x86_64.

I can confirm that this test passes on my Mac both with the vacuum before and after the pragma call. It's probably best to follow the documentation in this case. I'm expanding the patch to include the mac port as well.
Comment 4 Martin Robinson 2009-08-07 20:03:08 PDT
Created attachment 34356 [details]
Re-order the operations necessary for setting the maximum app cache size

If it's more appropriate to split this into two patches, let me know and I'll be happy to do that.
Comment 5 Jan Alonzo 2009-08-07 20:19:31 PDT
(In reply to comment #4)
> Created an attachment (id=34356) [details]
> Re-order the operations necessary for setting the maximum app cache size
> 
> If it's more appropriate to split this into two patches, let me know and I'll
> be happy to do that.

Maybe add more detail to the ChangeLog?
Comment 6 Eric Seidel (no email) 2009-08-07 20:51:31 PDT
Comment on attachment 34356 [details]
Re-order the operations necessary for setting the maximum app cache size

What I need to know to be able to review this is why changing the order does not cause the layout test to fail on Mac, but does in Gtk?

Perhaps others would have enough context to review this.
Comment 7 Martin Robinson 2009-08-07 21:25:37 PDT
Sorry. Let me try to clarify this. This test failed for me during the GTK+ tests, but has passed for others. I looked over the sqlite docs and it appears that according to the documentation, the order of these operations:

    WebCore::cacheStorage().empty();
    WebCore::cacheStorage().vacuumDatabaseFile();
    WebCore::cacheStorage().setMaximumSize(size);

should really be:

    WebCore::cacheStorage().empty();
    WebCore::cacheStorage().setMaximumSize(size);
    WebCore::cacheStorage().vacuumDatabaseFile();

Making that change caused my GTK+ test to pass. The test passes both before and after the same change is made to the CF port on my Macbook. The CF Mac port seems to be the only other port that does a vacuum when changing the maximum database size. The Qt port also does a .setMaximumSize(...) but never calls vacuum.

I'm new to this, so I'm not sure how I should structure the patch. It's clear that this fixes the test for my version of sqlite, but it's unclear why it was passing in the first place and why it only passes on some versions of sqlite.
Comment 8 Martin Robinson 2009-08-07 21:34:01 PDT
Created attachment 34359 [details]
Patch with more helpful Changelog entries
Comment 9 Martin Robinson 2009-08-07 21:35:25 PDT
Created attachment 34360 [details]
Patch with more helpful Changelog entries

Ack. Attached the wrong patch. Sorry.
Comment 10 Eric Seidel (no email) 2009-08-09 22:20:11 PDT
Comment on attachment 34360 [details]
Patch with more helpful Changelog entries

Ok.  So this looks fine.  Need one more round though.

We need a comment next to the code noting that the order is important.  The ChangeLog (and possibly the code comment) should ideally reference the SQLite docs which say that order matters here.

Again, the change looks totally fine.  The point I'm going for is that we should make sure that we make sure that no one will get this wrong again. :) (When they re-factor the code for instance.)

If you were a committer, I would just r+ this and you could fix it when you land.  Since you aren't, i'm going to ask that you post one more patch.

Thanks again for the patch!
Comment 11 Martin Robinson 2009-08-09 23:03:43 PDT
Looking over the SQLite docs again it seems my original patch is wrong, so I'm glad you r-'d it. I'll do more investigation into why the original test was failing. It may be related to the incomplete GTK+ database API.
Comment 12 Martin Robinson 2010-05-05 16:10:59 PDT
The test was just flaky and I don't see it any longer, so I'm closing this bug.