List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:December 8 2005 10:29am
Subject:bk commit into 5.0 tree (stewart:1.1992)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1992 05/12/08 11:29:08 stewart@stripped +2 -0
  Add utility to print the contents of the FragList file.
  
  Needed to help find a bug.
  
  Should be useful in the future (at least as a bit of documentation on
  the FragList file format).

  ndb/src/kernel/blocks/dbdih/printFragList.cpp
    1.1 05/12/08 11:29:04 stewart@stripped +169 -0
    New BitKeeper file ``ndb/src/kernel/blocks/dbdih/printFragList.cpp''

  ndb/src/kernel/blocks/dbdih/printFragList.cpp
    1.0 05/12/08 11:29:04 stewart@stripped +0 -0
    BitKeeper file /home/stewart/Documents/MySQL/5.0/printFragList/ndb/src/kernel/blocks/dbdih/printFragList.cpp

  ndb/src/kernel/blocks/dbdih/Makefile.am
    1.5 05/12/08 11:29:04 stewart@stripped +2 -1
    Add rules to build ndbd_fraglist_reader when asked to

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	stewart
# Host:	willster.(none)
# Root:	/home/stewart/Documents/MySQL/5.0/printFragList
--- New file ---
+++ ndb/src/kernel/blocks/dbdih/printFragList.cpp	05/12/08 11:29:04
#include <ndb_global.h>

#include <NdbMain.h>
#include <NdbOut.hpp>
#include <Sysfile.hpp>

void
usage(const char * prg){
  ndbout << "Usage " << prg
	 << " P[0-1].FragList" << endl;
}

struct page __attribute__ ((__packed__)){
  Uint32 padding[32];
  Uint32 data[480];
};

struct fraglist_header __attribute__ ((__packed__)){
  Uint32 padding[3];
  Uint32 totalFragments;
  Uint32 noOfBackups;
  Uint32 hashpointer;
  Uint32 kvalue;
  Uint32 mask;
  Uint32 type;
  Uint32 storedTable;
};

struct fragment __attribute__ ((__packed__)){
  Uint32 fid;
  Uint32 preferredPrimary;
  Uint32 noStoredReplicas;
  Uint32 noOldStoredReplicas;
  Uint32 distKey;
  // noStoredReplicas of struct replica
  // noOldStoredReplicas of struct replica
};

struct replica __attribute__ ((__packed__)){
  Uint32 procNode;
  Uint32 initialGci;
  Uint32 noCrashedReplicas;
  Uint32 nextLcp;
  struct lcp __attribute__ ((__packed__)){
    Uint32 maxGciCompleted;
    Uint32 maxGciStarted;
    Uint32 lcpId;
    Uint32 lcpStatus;
  } lcp[3];
  struct crashed_replicas __attribute__ ((__packed__)){
    Uint32 createGci;
    Uint32 replicaLastGci;
  } crashed_replicas[8]; // those >= noCrashedReplicas are not initialized
};

Uint32 readPageWord(FILE *f)
{
  static struct page p;
  static Uint32 where= sizeof(struct page);

  if(where >= sizeof(p.data))
  {
    // read next page
    Uint32 sz = fread(&p, 1, sizeof(struct page), f);
    if(sz != sizeof(struct page))
    {
      ndbout << "Unable to read complete page (only read " << sz
             << " bytes instead of " << sizeof(struct page)
             << " bytes). File is corrupt. " << endl;
      exit(1);
    }
    ndbout << " *** READ NEW PAGE *** " << endl;
    where= 0;
  }
  return p.data[where++];
}

void print(FILE *f)
{
  Uint32 i, k;
  struct fraglist_header flh;
  struct fragment frag;

  // read the fraglist header;
  for(i=0;i<sizeof(flh.padding)/sizeof(Uint32);i++)
    ndbout << "Padding " << i << " value " << readPageWord(f) << endl;


  ndbout << "FragList Header" << endl;
  ndbout << "---------------" << endl;
  ndbout << "totalFragments: " << readPageWord(f) << endl;
  ndbout << "noOfBackups:    " << readPageWord(f) << endl;
  ndbout << "hashpointer:    " << readPageWord(f) << endl;
  ndbout << "kvalue:         " << readPageWord(f) << endl;
  ndbout << "mask:           " << readPageWord(f) << endl;
  ndbout << "type:           " << readPageWord(f) << endl;
  ndbout << "storedTable:    " << readPageWord(f) << endl;
  ndbout << endl;

  // read the fragment
  ndbout << "Fragment" << endl;
  ndbout << "--------" << endl;
  ndbout << "fid:                 " << readPageWord(f) << endl;
  ndbout << "preferredPrimary:    " << readPageWord(f) << endl;
  frag.noStoredReplicas= readPageWord(f);
  ndbout << "noStoredReplicas:    " << frag.noStoredReplicas << endl;
  ndbout << "noOldStoredReplicas: " << readPageWord(f) << endl;
  ndbout << "distKey:             " << readPageWord(f) << endl;
  ndbout << endl;

  // read the noStoredReplicas
  ndbout << "Stored Replicas: " << endl;

  for(i=0;i<frag.noStoredReplicas;i++)
  {
    struct replica r;
    for(Uint32 *ptr=(Uint32*)&r;ptr<(Uint32*)&r+sizeof(struct replica)/sizeof(Uint32);ptr++)
      *ptr= readPageWord(f);
    ndbout << "procNode:          " << r.procNode << endl;
    ndbout << "initialGci:        " << r.initialGci << endl;
    ndbout << "noCrashedReplicas: " << r.noCrashedReplicas << endl;
    ndbout << "nextLcp:           " << r.nextLcp << endl;
    ndbout << "LCP:" << endl;
    ndbout << "maxGciCompleted maxGciStarted lcpId lcpStatus" << endl;
    for(k=0;k<3;k++)
    {
      ndbout << r.lcp[k].maxGciCompleted << "\t"
             << r.lcp[k].maxGciStarted << "\t"
             << r.lcp[k].lcpId << "\t"
             << r.lcp[k].lcpStatus << endl;
    }
    ndbout << "Crashed Replicas:" << endl;
    ndbout << "createGci replicaLastGci" << endl;
    for(k=0;k<r.noCrashedReplicas;k++)
    {
      ndbout << r.crashed_replicas[k].createGci << "\t"
             << r.crashed_replicas[k].replicaLastGci << endl;
    }
  }
}

NDB_COMMAND(printFragList,
	    "printFragList", "printFragList", "Prints a FragList file", 16384){ 
  if(argc < 2){
    usage(argv[0]);
    return 0;
  }

  for(int i = 1; i<argc; i++){
    const char * filename = argv[i];

    struct stat sbuf;
    const int res = stat(filename, &sbuf);
    if(res != 0){
      ndbout << "Could not find file: \"" << filename << "\"" << endl;
      continue;
    }
    FILE * f = fopen(filename, "rb");
    if(f == 0){
      ndbout << "Failed to open file" << endl;
      continue;
    }

    print(f);

    continue;
  }
  return 0;
}


--- 1.4/ndb/src/kernel/blocks/dbdih/Makefile.am	2005-08-31 23:24:46 +02:00
+++ 1.5/ndb/src/kernel/blocks/dbdih/Makefile.am	2005-12-08 11:29:04 +01:00
@@ -1,8 +1,9 @@
 noinst_LIBRARIES = libdbdih.a
-EXTRA_PROGRAMS = ndbd_sysfile_reader
+EXTRA_PROGRAMS = ndbd_sysfile_reader ndbd_fraglist_reader
 
 libdbdih_a_SOURCES = DbdihInit.cpp DbdihMain.cpp
 ndbd_sysfile_reader_SOURCES = printSysfile/printSysfile.cpp
+ndbd_fraglist_reader_SOURCES = printFragList.cpp
 
 include $(top_srcdir)/ndb/config/common.mk.am
 include $(top_srcdir)/ndb/config/type_kernel.mk.am
Thread
bk commit into 5.0 tree (stewart:1.1992)Stewart Smith8 Dec