Tars框架及Dcache返回的错误码一览

简介


看到这篇文章的同学,应该都知道Tars和Dcache了。

但在使用时,有时会遇到冰冷的数字:错误码。

由于没有文字描述性信息,还要回去查看各种文档,甚至查看源码。这是笔者的经历。

经过查找,找到了定义错误码的源文件,贴在此处,方便查阅。

最新定义以官方代码为主。

Tars框架错误码


tars错误码文件位于:tarscpp/servant/protocol/servant/BaseF.tars


module tars
{

// 定义协议的版本号

const short TARSVERSION = 0x01;
const short TUPVERSION = 0x03;
const short XMLVERSION = 0x04;
const short JSONVERSION = 0x05;


// 定义消息的类型

// 普通调用
const byte TARSNORMAL = 0x00;

// 单向调用
const byte TARSONEWAY = 0x01;


// TARS定义的返回码

const int TARSSERVERSUCCESS = 0; //服务器端处理成功
const int TARSSERVERDECODEERR = -1; //服务器端解码异常
const int TARSSERVERENCODEERR = -2; //服务器端编码异常
const int TARSSERVERNOFUNCERR = -3; //服务器端没有该函数
const int TARSSERVERNOSERVANTERR = -4; //服务器端没有该Servant对象
const int TARSSERVERRESETGRID = -5; //服务器端灰度状态不一致
const int TARSSERVERQUEUETIMEOUT = -6; //服务器队列超过限制
const int TARSASYNCCALLTIMEOUT = -7; //异步调用超时
const int TARSINVOKETIMEOUT = -7; //调用超时
const int TARSPROXYCONNECTERR = -8; //proxy链接异常
const int TARSSERVEROVERLOAD = -9; //服务器端超负载,超过队列长度
const int TARSADAPTERNULL = -10; //客户端选路为空,服务不存在或者所有服务down掉了
const int TARSINVOKEBYINVALIDESET = -11; //客户端按set规则调用非法
const int TARSCLIENTDECODEERR = -12; //客户端解码异常
const int TARSSERVERUNKNOWNERR = -99; //服务器端位置异常

/
// 定义按位的消息状态类型,可复合

const int TARSMESSAGETYPENULL = 0x00; //无状态
const int TARSMESSAGETYPEHASH = 0x01; //HASH消息
const int TARSMESSAGETYPEGRID = 0x02; //灰度消息
const int TARSMESSAGETYPEDYED = 0x04; //染色消息
const int TARSMESSAGETYPESAMPLE = 0x08; //stat采样消息
const int TARSMESSAGETYPEASYNC = 0x10; //异步调用程序
//const int TARSMESSAGETYPELOADED = 0x20; //按负载值调用程序
//const int TARSMESSAGETYPESETED = 0x40; //按set规则调用类型,此字段后面将不使用
const int TARSMESSAGETYPESETNAME = 0x80; //按setname规则调用类型
const int TARSMESSAGETYPETRACK = 0x100; //track调用链消息
/
};

Dcache错误码


错误描述定义在DCache/src/TarsComm/ProxyShare.tars

//proxy返回值定义
const int ET_SUCC = 0;
const int ET_SYS_ERR = -1;
const int ET_MODULE_NAME_INVALID = -2;
const int ET_KEY_INVALID = -3;
const int ET_KEY_AREA_ERR = -4;
const int ET_KEY_TYPE_ERR = -5;
const int ET_NO_DATA = -6;
const int ET_COMMAND_INVALID = -7;
const int ET_FORBID_DEL = -8;
const int ET_SERVER_TYPE_ERR = -9;
const int ET_DATA_EXIST = -10;
const int ET_FORBID_OPT = -11;
const int ET_INPUT_PARAM_ERROR = -12;
const int ET_ONLY_KEY = -13;
const int ET_DIRTY_DATA = -14;
const int ET_DATA_VER_MISMATCH = -15;
const int ET_PARTIAL_FAIL = -16; //用于二期批量insert数据时,表示部分数据set失败
const int ET_GZIP_UNCOMPRESS_ERR = -17; //用于数据有压缩时的解压缩失败
const int ET_CACHE_TYPE_ERR = -18; //用于节点间同步数据时,表示cache类型错误
const int ET_SYNC_SET_SAME = -19; //用于节点间同步数据时,表示同步set等于本地set
const int ET_SET_SYNC_NOENABLE = -20; //用于节点间同步数据时,表示该Proxy不支持节点间数据同步
const int ET_MEM_FULL = -21; //cache内存满
const int ET_DATA_TOO_MUCH = -22; //数据超过2w条
const int ET_READ_ONLY = -23; //cache只读,一般是在主备切换过程中产生
const int ET_DB_ERR = -24; //访问DB异常
const int ET_CACHE_ERR = -25; //访问cache异常
const int ET_PARAM_REDUNDANT = -26; //有重复字段或无效字段
const int ET_PARAM_MISSING = -27; //字段缺失
const int ET_PARAM_TOO_LONG = -28; //字段超长
const int ET_PARAM_DIGITAL_ERR = -29; //数字字段参数错误
const int ET_PARAM_NOT_EXIST = -30; //字段不存在,无效字段
const int ET_PARAM_OP_ERR = -31; //op错误
const int ET_PARAM_UKEY_MISSING = -32; //联合key字段缺失
const int ET_PARAM_UPDATE_UKEY_ERR = -33; //不允许更新联合key
const int ET_PARAM_LIMIT_VALUE_ERR = -34; //limit条件参数错误
const int ET_ERASE_DIRTY_ERR = -35; //不允许擦除脏数据
const int ET_DB_TO_CACHE_ERR = -36; //写DB返回数据到cache失败

const string DVER = "@DataVer";
const string EXPIRETIME = "@ExpireTime";
const string SCOREVALUE = "@ScoreValue";

//KV批量查询ret字段定义
const int VALUE_SUCC = 0;
const int VALUE_NO_DATA = 1;

//KV批量写入ret字段的定义
const int SET_SUCC = 0; //set成功
const int SET_ERROR = -1; //set失败
const int SET_DATA_VER_MISMATCH = -2; //set失败,具体原因是数据版本错误

//KV,MKV批量erase、del返回值字段的定义
const int DEL_SUCC = 0; //删除成功
const int DEL_ERROR = -1; //删除失败
const int DEL_DATA_VER_MISMATCH = -2; //删除失败,具体原因是数据版本错误

//KV,MKV批量写时返回值字段的定义 
const int WRITE_SUCC = 0; //写成功
const int WRITE_ERROR = -1; //写失败
const int WRITEL_DATA_VER_MISMATCH = -2; //写失败,具体原因是数据版本错误

小结


根据笔者经历,Tars错误多是超时错误(-6,-7),Dcache错误多是-3、-28等。

有了这个错误描述,方便大家查找定位bug。


版权声明:本文为guotianqing原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。