changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[livejournal] r14819: LJSUP-3708: Community ontd has reached m...

Committer: gariev
LJSUP-3708: Community ontd has reached max int24 comment id (jtalkid)

U   trunk/bin/upgrading/update-db-general.pl
U   trunk/cgi-bin/talklib.pl
U   trunk/htdocs/admin/memcache_view.bml
Modified: trunk/bin/upgrading/update-db-general.pl
===================================================================
--- trunk/bin/upgrading/update-db-general.pl	2009-01-29 09:52:34 UTC (rev 14818)
+++ trunk/bin/upgrading/update-db-general.pl	2009-01-29 10:01:06 UTC (rev 14819)
@@ -927,10 +927,10 @@
 register_tablecreate("talk2", <<'EOC');
 CREATE TABLE talk2 (
   journalid INT UNSIGNED NOT NULL,
-  jtalkid MEDIUMINT UNSIGNED NOT NULL,
+  jtalkid INT UNSIGNED NOT NULL,
   nodetype CHAR(1) NOT NULL DEFAULT '',
   nodeid INT UNSIGNED NOT NULL default '0',
-  parenttalkid MEDIUMINT UNSIGNED NOT NULL,
+  parenttalkid INT UNSIGNED NOT NULL,
   posterid INT UNSIGNED NOT NULL default '0',
   datepost DATETIME NOT NULL default '0000-00-00 00:00:00',
   state CHAR(1) default 'A',
@@ -944,7 +944,7 @@
 register_tablecreate("talkprop2", <<'EOC');
 CREATE TABLE talkprop2 (
   journalid INT UNSIGNED NOT NULL,
-  jtalkid MEDIUMINT UNSIGNED NOT NULL,
+  jtalkid INT UNSIGNED NOT NULL,
   tpropid TINYINT UNSIGNED NOT NULL,
   value VARCHAR(255) DEFAULT NULL,
   PRIMARY KEY  (journalid,jtalkid,tpropid)
@@ -954,7 +954,7 @@
 register_tablecreate("talktext2", <<'EOC');
 CREATE TABLE talktext2 (
   journalid INT UNSIGNED NOT NULL,
-  jtalkid MEDIUMINT UNSIGNED NOT NULL,
+  jtalkid INT UNSIGNED NOT NULL,
   subject VARCHAR(100) DEFAULT NULL,
   body TEXT,
   PRIMARY KEY (journalid, jtalkid)
@@ -970,7 +970,7 @@
   nodetype   CHAR(1) NOT NULL,
   nodeid     INT UNSIGNED NOT NULL,
   INDEX (journalid, nodetype, nodeid),
-  jtalkid    MEDIUMINT UNSIGNED NOT NULL,
+  jtalkid    INT UNSIGNED NOT NULL,
   publicitem   ENUM('1','0') NOT NULL DEFAULT '1'
 )
 EOC
@@ -984,7 +984,7 @@
   nodetype   CHAR(1) NOT NULL,
   nodeid     INT UNSIGNED NOT NULL,
   INDEX (journalid, nodetype, nodeid),
-  jtalkid    MEDIUMINT UNSIGNED NOT NULL,
+  jtalkid    INT UNSIGNED NOT NULL,
   publicitem   ENUM('1','0') NOT NULL DEFAULT '1'
 )
 EOC
@@ -1724,7 +1724,7 @@
 CREATE TABLE commenturls (
    posterid int unsigned NOT NULL,
    journalid int unsigned NOT NULL,
-   jtalkid mediumint unsigned NOT NULL,
+   jtalkid int unsigned NOT NULL,
    timecreate int unsigned NOT NULL,
    url varchar(255) NOT NULL,
    INDEX (timecreate)
@@ -3916,6 +3916,49 @@
                  "ALTER TABLE supportlog " .
                  "ADD tier TINYINT UNSIGNED DEFAULT NULL");
     }
+    
+    if (column_type("talk2", "jtalkid") =~ /mediumint/) {
+        do_alter("talk2",
+                 "ALTER TABLE talk2 " .
+                 "MODIFY jtalkid INT UNSIGNED NOT NULL");
+    }
+    
+    if (column_type("talk2", "parenttalkid") =~ /mediumint/) {
+        do_alter("talk2",
+                 "ALTER TABLE talk2 " .
+                 "MODIFY parenttalkid INT UNSIGNED NOT NULL");
+    }
+    
+    if (column_type("talkprop2", "jtalkid") =~ /mediumint/) {
+        do_alter("talkprop2",
+                 "ALTER TABLE talkprop2 " .
+                 "MODIFY jtalkid INT UNSIGNED NOT NULL");
+    }
+    
+    if (column_type("talktext2", "jtalkid") =~ /mediumint/) {
+        do_alter("talktext2",
+                 "ALTER TABLE talktext2 " .
+                 "MODIFY jtalkid INT UNSIGNED NOT NULL");
+    }
+
+    if (column_type("talkleft", "jtalkid") =~ /mediumint/) {
+        do_alter("talkleft",
+                 "ALTER TABLE talkleft " .
+                 "MODIFY jtalkid INT UNSIGNED NOT NULL");
+    }
+
+    if (column_type("talkleft_xfp", "jtalkid") =~ /mediumint/) {
+        do_alter("talkleft_xfp",
+                 "ALTER TABLE talkleft_xfp " .
+                 "MODIFY jtalkid INT UNSIGNED NOT NULL");
+    }
+
+    if (column_type("commenturls", "jtalkid") =~ /mediumint/) {
+        do_alter("commenturls",
+                 "ALTER TABLE commenturls " .
+                 "MODIFY jtalkid INT UNSIGNED NOT NULL");
+    }
+
 });
 
 

Modified: trunk/cgi-bin/talklib.pl
===================================================================
--- trunk/cgi-bin/talklib.pl	2009-01-29 09:52:34 UTC (rev 14818)
+++ trunk/cgi-bin/talklib.pl	2009-01-29 10:01:06 UTC (rev 14819)
@@ -685,7 +685,10 @@
     my $ret = {};
 
     # check for data in memcache
-    my $DATAVER = "1";  # single character
+    my $DATAVER = "2";  # single character
+    my $PACK_FORMAT = "NNNNC"; ## $talkid, $parenttalkid, $poster, $time, $state
+    my $RECORD_SIZE = 17;   
+    
     my $memkey = [$u->{'userid'}, "talk2:$u->{'userid'}:$nodetype:$nodeid"];
     my $lockkey = $memkey->[1];
     my $packed = LJ::MemCache::get($memkey);
@@ -752,15 +755,13 @@
 
     my $memcache_good = sub {
         return $packed && substr($packed,0,1) eq $DATAVER &&
-            length($packed) % 16 == 1;
+            length($packed) % $RECORD_SIZE == 1;
     };
 
     my $memcache_decode = sub {
-        my $n = (length($packed) - 1) / 16;
+        my $n = (length($packed) - 1) / $RECORD_SIZE;
         for (my $i=0; $i<$n; $i++) {
-            my ($f1, $par, $poster, $time) = unpack("NNNN",substr($packed,$i*16+1,16));
-            my $state = chr($f1 & 255);
-            my $talkid = $f1 >> 8;
+            my ($talkid, $par, $poster, $time, $state) = unpack($PACK_FORMAT,substr($packed,$i*$RECORD_SIZE+1,$RECORD_SIZE));
             $ret->{$talkid} = {
                 talkid => $talkid,
                 state => $state,
@@ -826,11 +827,12 @@
             LJ::Talk::add_talk2row_memcache($u->id, $r->{talkid}, \%row_arg);
         }
 
-        $memval .= pack("NNNN",
-                        ($r->{'talkid'} << 8) + ord($r->{'state'}),
+        $memval .= pack($PACK_FORMAT,
+                        $r->{'talkid'},
                         $r->{'parenttalkid'},
                         $r->{'posterid'},
-                        $r->{'datepost_unix'});
+                        $r->{'datepost_unix'},
+                        $r->{'state'});
 
         $rp_ourcount++ if $r->{'state'} eq "A";
     }

Modified: trunk/htdocs/admin/memcache_view.bml
===================================================================
--- trunk/htdocs/admin/memcache_view.bml	2009-01-29 09:52:34 UTC (rev 14818)
+++ trunk/htdocs/admin/memcache_view.bml	2009-01-29 10:01:06 UTC (rev 14819)
@@ -84,17 +84,19 @@
      # unpack packed data
      if ($key =~ /^talk2:/) {
          my $newval;
-         my $n = (length($val) - 1) / 16;
+         my $DATAVER = "2";  # single character
+         my $PACK_FORMAT = "NNNNC"; ## $talkid, $parenttalkid, $poster, $time, $state
+         my $RECORD_SIZE = 17;
+                     
+         my $n = (length($val) - 1) / $RECORD_SIZE;
          for (my $i=0; $i<$n; $i++) {
-             my ($f1, $par, $poster, $time) = unpack("NNNN",substr($val,$i*16+1,16));
-             my $state = chr($f1 & 255);
-             my $talkid = $f1 >> 8;
+             my ($talkid, $parenttalkid, $poster, $time, $state) = unpack($PACK_FORMAT,substr($val,$i*$RECORD_SIZE+1,$RECORD_SIZE));
              $newval->{$talkid} = {
                  talkid => $talkid,
                  state => $state,
                  posterid => $poster,
                  datepost => LJ::mysql_time($time),
-                 parenttalkid => $par,
+                 parenttalkid => $parenttalkid,
              };
          }
          $val = [substr($val,0,1), $newval];

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 16 comments