How to view the DDL jobs in TiDB? - ddl

When I was trying TiDB, I ran into the condition that it was slow to add indexes. I want to view the progress, but how to view the DDL jobs in TiDB?

You can use admin show ddl to view the current job of adding an index or the running DDL jobs.
As for viewing DDL jobs, you can also use two other commands as follows:
admin show ddl jobs: to view all the results in the current DDL job queue (including tasks that are running and waiting to run) and the last ten results in the completed DDL job queue
admin show ddl job queries 'job_id' [, 'job_id'] ...: to view the original SQL statement of the DDL task corresponding to the job_id; the job_id only searches the running DDL job and the last ten results in the DDL history job queue

Related

Oracle materialized view - rebuiliding que

I have a series of materialized views in Oracle. The content of next mview depends on content in previous one. So I'd like to create a schedule for these mviews where the next rebuild process starts when previous mview finishes its own rebuilding process. I cannot predict how long rebuilding process will take so I'd like to put them in kinda rebuilding que.
How to do that?
Use Oracle Scheduler to build a job chain to refresh them in the order desired. You can even have steps in the chain execute in parallel if there are dependencies that allow it, then have later steps wait for all of the parallel steps to complete before proceeding.
Create stored procedures to refresh each materialized view.
Create Scheduler Programs for each stored procedure.
Create a Scheduler Job Chain with Steps for each Scheduler program. Include Rules to control the order of Step execution.
Create a Scheduler Job to start the Chain execution at the desired time/interval.
See here for documentation and examples:
Scheduling Jobs with Oracle Scheduler
How To Do It In Parallel
Scheduler in Oracle Database 10g Onward

Oracle Advanced Queues versus a Small Oracle Database Table

I'm looking for a simple way to communicate between two databases, there currently exists a database link between both database.
I want to process a job on database 1 for a batch of records (batch code for each batch of records), once the process has finished on database 1 and all the batches of records have been processed. I want database 2 to see that database 1 has processed a number of batches (batch codes) either by querying a oracle table or an Oracle advanced queue which sits on either database 1 or database 2.
Database 2 will process the batches of records that are on database 1 through a database linked view using each batch code and update the status of that batch to complete.
I want to be able to update the Oracle Advanced Queue or database table of its batch no, progress status ('S' started, 'C' completed), status date
Table name.
batch_records
Table columns
Batch No,
Status,
status date
Questions:
Can this be done by a simple database table rather than a complex Oracle Advanced Queue?
Can a table be updated over a database link?
Are there any examples of this?
To answer your question first:
yes, I believe so
yes, it can. But, if there are many rows involved, it can be pretty slow
probably
Database link is the way to communicate between two databases. If those jobs run on the database 1 (DB1), I'd suggest you to keep it there - in the DB1. Doing stuff over a database link calls for problems of different kinds. Might be slow, you can't do everything over the database link (LOBs, for example). One option is to schedule a job (using DBMS_SCHEDULER or DBMS_JOB (which is quite OK for simple things)). Let the procedure maintain job status in some table (that would be a "simple table" from your 1st question) in DB1 which will be read by the DB2.
How? Do it directly, or create a materialized view which will be refreshed in a scheduled manner (e.g. every morning at 07:00) or on demand (not that good idea) or on commit (once the DB1 procedure does the job and commits changes, materialized view will be refreshed).
If there aren't that many rows involved, I'd probably read the DB1 status table directly, and think of other options later (if necessary).

Oracle DB Audit ALL

I have a 5TB large database.
I want to audit everything , really everything.
First of all, I tried with AUDIT ALL, but according to Oracle's document AUDIT ALL does NOT audit everything...
I know that this statement must be executed in order to start auditing db:
alter system set audit_trail=db,extended scope=spfile;
But what else should I do to start auditing all the SQL statements that users execute?
You need not to use the AUDIT feature if you only want a view on user queries (SELECT, UPDATE, INSERT) on your database. $AUD contains rather DDL statements, whereas V$SQL contains only DML statements.
A very simple solution is to use another view: V$SQL. You can extract duration and lot of useful info from it.
Useful example:
SELECT * FROM v$sql vv
WHERE lower(vv.SQL_TEXT) like '%delete%'
AND vv.PARSING_SCHEMA_NAME like 'A_SCHEMA%'
ORDER BY vv.LAST_ACTIVE_TIME desc;
V$SQL lists statistics on shared SQL area without the GROUP BY clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL are normally updated at the end of query execution.
Long running queries are updated every 5 seconds. This shows the impact of long running SQLs while they are still working.

How to reset mload after job?

I am running an mload script on a table that is cleared at the beginning of a job. When the script fails, the error and log tables prevent the job from running a second time. How does one reset mload cleanly after a failure?
You need to drop the work/error/log table
DROP TABLE UV_mytable;
DROP TABLE ET_mytable;
DROP TABLE WT_mytable;
DROP TABLE LT_mytable;
And then release the load lock:
RELEASE MLOAD mytable;,
If this fails
RELEASE MLOAD mytable IN APPLY;
But why does the job fail at all?

Hive Locks entire database when running select on one table

HIVE 0.13 will SHARED lock the entire database(I see a node like LOCK-0000000000 as a child of the database node in Zookeeper) when running a select statement on any table in the database. HIVE creates a shared lock on the entire schema even when running a select statement - this results in a freeze on CREATE/DELETE statements on other tables in the database until the original query finishes and the lock is released.
Does anybody know a way around this? Following link suggests concurrency to be turned off but we can't do that as we are replacing the entire table and we have to make sure that no select statement is accessing the table before we replace the entire contents.
http://mail-archives.apache.org/mod_mbox/hive-user/201408.mbox/%3C0eba01cfc035$3501e4f0$9f05aed0$#com%3E
use mydatabase;
select count(*) from large_table limit 1; # this table is very large and hive.support.concurrency=true`
In another hive shell, meanwhile the 1st query is executing:
use mydatabase;
create table sometable (id string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' STORED AS TEXTFILE ;
The problem is that the “create table” does not execute untill the first query (select) has finished.
Update:
We are using Cloudera's distribution of Hive CDH-5.2.1-1 and we are seeing this issue.
I think they never made such that in Hive 0.13. Please verify your Resource manager and see that you have enough memory when you are executing multiple Hive queries.
As you know each Hive query will trigger a map reduce job and if YARN doesn't have enough resources it will wait till the previous running job completes. Please approach your issue from memory point of view.
All the best !!

Resources