Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
49a4bbe1
Commit
49a4bbe1
authored
Aug 24, 2013
by
Kentoku SHIBA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spider_general_log and spider_log_result_errors feature.
parent
e1fc2f4d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
167 additions
and
2 deletions
+167
-2
storage/spider/hs_client/hstcpcli.cpp
storage/spider/hs_client/hstcpcli.cpp
+2
-0
storage/spider/hs_client/hstcpcli.hpp
storage/spider/hs_client/hstcpcli.hpp
+2
-0
storage/spider/spd_db_conn.cc
storage/spider/spd_db_conn.cc
+34
-0
storage/spider/spd_db_handlersocket.cc
storage/spider/spd_db_handlersocket.cc
+18
-0
storage/spider/spd_db_mysql.cc
storage/spider/spd_db_mysql.cc
+46
-1
storage/spider/spd_db_oracle.cc
storage/spider/spd_db_oracle.cc
+16
-0
storage/spider/spd_include.h
storage/spider/spd_include.h
+1
-1
storage/spider/spd_param.cc
storage/spider/spd_param.cc
+46
-0
storage/spider/spd_param.h
storage/spider/spd_param.h
+2
-0
No files found.
storage/spider/hs_client/hstcpcli.cpp
View file @
49a4bbe1
...
@@ -77,6 +77,8 @@ struct hstcpcli : public hstcpcli_i, private noncopyable {
...
@@ -77,6 +77,8 @@ struct hstcpcli : public hstcpcli_i, private noncopyable {
virtual
size_t
get_response_end_offset
()
{
return
response_end_offset
;
}
virtual
size_t
get_response_end_offset
()
{
return
response_end_offset
;
}
virtual
const
char
*
get_readbuf_begin
()
{
return
readbuf
.
begin
();
}
virtual
const
char
*
get_readbuf_begin
()
{
return
readbuf
.
begin
();
}
virtual
const
char
*
get_readbuf_end
()
{
return
readbuf
.
end
();
}
virtual
const
char
*
get_readbuf_end
()
{
return
readbuf
.
end
();
}
virtual
const
char
*
get_writebuf_begin
()
{
return
writebuf
.
begin
();
}
virtual
size_t
get_writebuf_size
()
{
return
writebuf
.
size
();
}
virtual
void
write_error_to_log
(
const
char
*
func_name
,
const
char
*
file_name
,
virtual
void
write_error_to_log
(
const
char
*
func_name
,
const
char
*
file_name
,
ulong
line_no
);
ulong
line_no
);
private:
private:
...
...
storage/spider/hs_client/hstcpcli.hpp
View file @
49a4bbe1
...
@@ -82,6 +82,8 @@ struct hstcpcli_i {
...
@@ -82,6 +82,8 @@ struct hstcpcli_i {
virtual
size_t
get_response_end_offset
()
=
0
;
virtual
size_t
get_response_end_offset
()
=
0
;
virtual
const
char
*
get_readbuf_begin
()
=
0
;
virtual
const
char
*
get_readbuf_begin
()
=
0
;
virtual
const
char
*
get_readbuf_end
()
=
0
;
virtual
const
char
*
get_readbuf_end
()
=
0
;
virtual
const
char
*
get_writebuf_begin
()
=
0
;
virtual
size_t
get_writebuf_size
()
=
0
;
virtual
void
write_error_to_log
(
const
char
*
func_name
,
const
char
*
file_name
,
virtual
void
write_error_to_log
(
const
char
*
func_name
,
const
char
*
file_name
,
ulong
line_no
)
=
0
;
ulong
line_no
)
=
0
;
static
hstcpcli_ptr
create
(
const
socket_args
&
args
);
static
hstcpcli_ptr
create
(
const
socket_args
&
args
);
...
...
storage/spider/spd_db_conn.cc
View file @
49a4bbe1
...
@@ -682,6 +682,17 @@ int spider_db_errorno(
...
@@ -682,6 +682,17 @@ int spider_db_errorno(
)
{
)
{
push_warning
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
push_warning
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
error_num
,
conn
->
db_conn
->
get_error
());
error_num
,
conn
->
db_conn
->
get_error
());
if
(
spider_param_log_result_errors
()
>=
3
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
struct
tm
*
l_time
=
localtime_r
(
&
cur_time
,
&
lt
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] "
"to %ld: %d %s
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
current_thd
->
thread_id
,
error_num
,
conn
->
db_conn
->
get_error
());
}
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
{
{
SPIDER_CLEAR_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
SPIDER_CLEAR_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
...
@@ -691,6 +702,17 @@ int spider_db_errorno(
...
@@ -691,6 +702,17 @@ int spider_db_errorno(
}
}
*
conn
->
need_mon
=
error_num
;
*
conn
->
need_mon
=
error_num
;
my_message
(
error_num
,
conn
->
db_conn
->
get_error
(),
MYF
(
0
));
my_message
(
error_num
,
conn
->
db_conn
->
get_error
(),
MYF
(
0
));
if
(
spider_param_log_result_errors
()
>=
1
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
struct
tm
*
l_time
=
localtime_r
(
&
cur_time
,
&
lt
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [ERROR SPIDER RESULT] "
"to %ld: %d %s
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
current_thd
->
thread_id
,
error_num
,
conn
->
db_conn
->
get_error
());
}
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
{
{
SPIDER_CLEAR_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
SPIDER_CLEAR_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
...
@@ -725,6 +747,18 @@ int spider_db_errorno(
...
@@ -725,6 +747,18 @@ int spider_db_errorno(
}
}
my_printf_error
(
ER_SPIDER_HS_NUM
,
ER_SPIDER_HS_STR
,
MYF
(
0
),
my_printf_error
(
ER_SPIDER_HS_NUM
,
ER_SPIDER_HS_STR
,
MYF
(
0
),
conn
->
db_conn
->
get_errno
(),
conn
->
db_conn
->
get_error
());
conn
->
db_conn
->
get_errno
(),
conn
->
db_conn
->
get_error
());
if
(
spider_param_log_result_errors
()
>=
1
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
struct
tm
*
l_time
=
localtime_r
(
&
cur_time
,
&
lt
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [ERROR SPIDER RESULT] "
"to %ld: %d %s
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
current_thd
->
thread_id
,
conn
->
db_conn
->
get_errno
(),
conn
->
db_conn
->
get_error
());
}
*
conn
->
need_mon
=
ER_SPIDER_HS_NUM
;
*
conn
->
need_mon
=
ER_SPIDER_HS_NUM
;
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
{
{
...
...
storage/spider/spd_db_handlersocket.cc
View file @
49a4bbe1
...
@@ -1061,6 +1061,24 @@ int spider_db_handlersocket::exec_query(
...
@@ -1061,6 +1061,24 @@ int spider_db_handlersocket::exec_query(
(
*
hs_conn_p
)
->
get_num_req_rcvd
()));
(
*
hs_conn_p
)
->
get_num_req_rcvd
()));
DBUG_PRINT
(
"info"
,(
"spider hs response_end_offset=%zu"
,
DBUG_PRINT
(
"info"
,(
"spider hs response_end_offset=%zu"
,
(
*
hs_conn_p
)
->
get_response_end_offset
()));
(
*
hs_conn_p
)
->
get_response_end_offset
()));
if
(
spider_param_general_log
())
{
const
char
*
tgt_str
=
conn
->
hs_sock
?
conn
->
hs_sock
:
conn
->
tgt_host
;
uint32
tgt_len
=
strlen
(
tgt_str
);
spider_string
tmp_query_str
((
*
hs_conn_p
)
->
get_writebuf_size
()
+
conn
->
tgt_wrapper_length
+
tgt_len
+
(
SPIDER_SQL_SPACE_LEN
*
2
));
tmp_query_str
.
init_calc_mem
(
231
);
tmp_query_str
.
length
(
0
);
tmp_query_str
.
q_append
(
conn
->
tgt_wrapper
,
conn
->
tgt_wrapper_length
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
(
tgt_str
,
tgt_len
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
((
*
hs_conn_p
)
->
get_writebuf_begin
(),
(
*
hs_conn_p
)
->
get_writebuf_size
());
general_log_write
(
current_thd
,
COM_QUERY
,
tmp_query_str
.
ptr
(),
tmp_query_str
.
length
());
}
if
((
*
hs_conn_p
)
->
request_send
()
<
0
)
if
((
*
hs_conn_p
)
->
request_send
()
<
0
)
{
{
DBUG_PRINT
(
"info"
,(
"spider hs num_req_bufd=%zu"
,
DBUG_PRINT
(
"info"
,(
"spider hs num_req_bufd=%zu"
,
...
...
storage/spider/spd_db_mysql.cc
View file @
49a4bbe1
...
@@ -1475,9 +1475,54 @@ int spider_db_mysql::exec_query(
...
@@ -1475,9 +1475,54 @@ int spider_db_mysql::exec_query(
uint
length
,
uint
length
,
int
quick_mode
int
quick_mode
)
{
)
{
int
error_num
;
DBUG_ENTER
(
"spider_db_mysql::exec_query"
);
DBUG_ENTER
(
"spider_db_mysql::exec_query"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
DBUG_RETURN
(
mysql_real_query
(
db_conn
,
query
,
length
));
if
(
spider_param_general_log
())
{
const
char
*
tgt_str
=
conn
->
tgt_host
;
uint32
tgt_len
=
conn
->
tgt_host_length
;
spider_string
tmp_query_str
(
length
+
conn
->
tgt_wrapper_length
+
tgt_len
+
(
SPIDER_SQL_SPACE_LEN
*
2
));
tmp_query_str
.
init_calc_mem
(
230
);
tmp_query_str
.
length
(
0
);
tmp_query_str
.
q_append
(
conn
->
tgt_wrapper
,
conn
->
tgt_wrapper_length
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
(
tgt_str
,
tgt_len
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
(
query
,
length
);
general_log_write
(
current_thd
,
COM_QUERY
,
tmp_query_str
.
ptr
(),
tmp_query_str
.
length
());
}
error_num
=
mysql_real_query
(
db_conn
,
query
,
length
);
if
(
spider_param_log_result_errors
()
>=
2
&&
db_conn
->
warning_count
>
0
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
struct
tm
*
l_time
=
localtime_r
(
&
cur_time
,
&
lt
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] "
"from [%s] %ld to %ld: "
"affected_rows: %llu id: %llu status: %u warning_count: %u
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
current_thd
->
thread_id
,
db_conn
->
affected_rows
,
db_conn
->
insert_id
,
db_conn
->
server_status
,
db_conn
->
warning_count
);
}
else
if
(
spider_param_log_result_errors
()
>=
4
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
struct
tm
*
l_time
=
localtime_r
(
&
cur_time
,
&
lt
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [INFO SPIDER RESULT] "
"from [%s] %ld to %ld: "
"affected_rows: %llu id: %llu status: %u warning_count: %u
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
current_thd
->
thread_id
,
db_conn
->
affected_rows
,
db_conn
->
insert_id
,
db_conn
->
server_status
,
db_conn
->
warning_count
);
}
DBUG_RETURN
(
error_num
);
}
}
int
spider_db_mysql
::
get_errno
()
int
spider_db_mysql
::
get_errno
()
...
...
storage/spider/spd_db_oracle.cc
View file @
49a4bbe1
...
@@ -1403,6 +1403,22 @@ int spider_db_oracle::exec_query(
...
@@ -1403,6 +1403,22 @@ int spider_db_oracle::exec_query(
int
error_num
;
int
error_num
;
DBUG_ENTER
(
"spider_db_oracle::exec_query"
);
DBUG_ENTER
(
"spider_db_oracle::exec_query"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
if
(
spider_param_general_log
())
{
const
char
*
tgt_str
=
conn
->
tgt_host
;
uint32
tgt_len
=
conn
->
tgt_host_length
;
spider_string
tmp_query_str
(
length
+
conn
->
tgt_wrapper_length
+
tgt_len
+
(
SPIDER_SQL_SPACE_LEN
*
2
));
tmp_query_str
.
init_calc_mem
(
232
);
tmp_query_str
.
length
(
0
);
tmp_query_str
.
q_append
(
conn
->
tgt_wrapper
,
conn
->
tgt_wrapper_length
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
(
tgt_str
,
tgt_len
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
(
query
,
length
);
general_log_write
(
current_thd
,
COM_QUERY
,
tmp_query_str
.
ptr
(),
tmp_query_str
.
length
());
}
stored_error_num
=
0
;
stored_error_num
=
0
;
if
(
table_lock_mode
&&
!
conn
->
in_before_query
)
if
(
table_lock_mode
&&
!
conn
->
in_before_query
)
{
{
...
...
storage/spider/spd_include.h
View file @
49a4bbe1
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
#define SPIDER_TMP_SHARE_LONG_COUNT 15
#define SPIDER_TMP_SHARE_LONG_COUNT 15
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 23
0
#define SPIDER_MEM_CALC_LIST_NUM 23
3
#define SPIDER_BACKUP_DASTATUS \
#define SPIDER_BACKUP_DASTATUS \
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
...
...
storage/spider/spd_param.cc
View file @
49a4bbe1
...
@@ -2783,6 +2783,50 @@ int spider_param_udf_ds_use_real_table(
...
@@ -2783,6 +2783,50 @@ int spider_param_udf_ds_use_real_table(
}
}
#endif
#endif
static
my_bool
spider_general_log
;
static
MYSQL_SYSVAR_BOOL
(
general_log
,
spider_general_log
,
PLUGIN_VAR_OPCMDARG
,
"Log query to remote server in general log"
,
NULL
,
NULL
,
FALSE
);
my_bool
spider_param_general_log
()
{
DBUG_ENTER
(
"spider_param_general_log"
);
DBUG_RETURN
(
spider_general_log
);
}
static
uint
spider_log_result_errors
;
/*
0: no log
1: log error
2: log warning summary
3: log warning
4: log info
*/
static
MYSQL_SYSVAR_UINT
(
log_result_errors
,
spider_log_result_errors
,
PLUGIN_VAR_RQCMDARG
,
"Log error from remote server in error log"
,
NULL
,
NULL
,
0
,
0
,
4
,
0
);
uint
spider_param_log_result_errors
()
{
DBUG_ENTER
(
"spider_param_log_result_errors"
);
DBUG_RETURN
(
spider_log_result_errors
);
}
static
struct
st_mysql_storage_engine
spider_storage_engine
=
static
struct
st_mysql_storage_engine
spider_storage_engine
=
{
MYSQL_HANDLERTON_INTERFACE_VERSION
};
{
MYSQL_HANDLERTON_INTERFACE_VERSION
};
...
@@ -2908,6 +2952,8 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
...
@@ -2908,6 +2952,8 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
#else
#else
MYSQL_SYSVAR
(
udf_ds_use_real_table
),
MYSQL_SYSVAR
(
udf_ds_use_real_table
),
#endif
#endif
MYSQL_SYSVAR
(
general_log
),
MYSQL_SYSVAR
(
log_result_errors
),
NULL
NULL
};
};
...
...
storage/spider/spd_param.h
View file @
49a4bbe1
...
@@ -368,3 +368,5 @@ int spider_param_udf_ds_use_real_table(
...
@@ -368,3 +368,5 @@ int spider_param_udf_ds_use_real_table(
int
udf_ds_use_real_table
int
udf_ds_use_real_table
);
);
#endif
#endif
my_bool
spider_param_general_log
();
uint
spider_param_log_result_errors
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment