How to analyze why ReplicasMaxAbsoluteDelay return current time problem? - apache-zookeeper

Sometimes when the zabbix monitor executes the sql "select value from system.asynchronous_metrics where metric='ReplicasMaxAbsoluteDelay';", it will return a very large value like "52y 9m 18d" (currenttime - 1970).
According to the getAbsoluteDelay() function, we knew when queue_update_finish_time is null, this function will return current_time.
But we want to analyze when and why queue_update_finish_time is null, what can we check from clickhouse system table or log ? We've checked the error log and zookeeper log, but it seems there is no infomation about this problem.
Thanks.

Usually it means table is out-of-sync and gone in read only mode.
Read-only mode can be caused by:
some zookeeper synchronization issue
out of disk storage
stale metadata (replica had failed to apply some alter)
...
To get more information try look into system.replicas table:
SELECT is_readonly, zookeeper_exception
FROM system.replicas
WHERE table = 'appsflyer_events_hist'
In most cases it helps to run:
SYSTEM RESTART REPLICA db.table
https://clickhouse.com/docs/en/sql-reference/statements/system/#restart-replica

Related

Liquibase Validation Failed Exception - change sets check sum

After launch the application, I get an error:
Caused by: liquibase.exception.ValidationFailedException: Validation Failed: 1 change sets checksum was: 8:2b2936713e8d9aea052c3122fd81faec but now it is:
8:ed8f7550fdd9809f4f6bf0f2d83dbbd8
The error points to such a table:
create table car (
id bigint not null auto_increment PRIMARY KEY,
name varchar(255) not null,
category varchar(255) not null
);
I read about this error and it was pointed out to use the mvn liquibase:clearCheckSums command but in the terminal I get the error: Error: -classpath requires class path specification (I run the command in the project folder)
The error indicates that a changelog that already run now is running with some changes. If you change something on an already run changelog then the checksum changes and this error is completely normal.
Check your databasechangelog table for the mentioned checksum to verify the changelog that crashes. The solutions are usually not to change the checksum of an already run changelog. If you can drop this changelog from the database and run it again will work fine. Sometimes the same changelog crashes without changing anything. This happening to me all the time because of the line seperator. For example, on IntleliJ you can change it from here:
Check what line separator do you need by testing :)

Disable logging of logical replication statements in Postgres 13.1

I have a simple process that is reading logical replication messages from postgres. This process runs every second and generates a lot of messages in the postgres logs like:
2021-02-15 20:35:11.032 UTC [35] STATEMENT: SELECT * FROM pg_logical_slot_get_changes('lazy_cloud', NULL, NULL);
2021-02-15 20:35:11.032 UTC [35] LOG: logical decoding found consistent point at 0/167C618
2021-02-15 20:35:11.032 UTC [35] DETAIL: There are no running transactions.
I've configured logging with the following settings:
log_min_messages=ERROR
log_statement=none
log_replication_commands=0
But, the logical replication logs are still produced.
Is there a setting to disable these messages? I can use sed or something like that, but would prefer a built in solution.
There is no way to disable that message short of setting
log_min_messages = fatal
in postgresql.conf, but that is not a smart idea, because then you'd miss out on all error messages in the log file and essentially disable logging.

SQL0443 error when executing a Select with a Trigger on DB2 for iSeries

I've some problem querying a db2/as400 table, let's call it TAB1. Since it was added a trigger on this table when I perform a normal SELECT (using the TAB1-key) I get the following error. Never had a problem before the trigger was created.
It's a query performed in a batch-application (Java 1.6) using Modern Batch and Spring Batch 2.1.8. No chance to update the libraries, since the program is quite old and the customers won't agree.
Anyway,I would say it's a trigger problem ( as the sql codes say) but different applications perform different SELECTs on TAB1 and they never get any similar problem.The batch perform more or less 40000 select like this, and just 300 fail with this error.
Any idea, tip, suggestion?
### Error querying database. Cause: java.sql.SQLException: [SQL0443] *N *N
### The error may exist in class path resource [eu/mycompany/el20/dq/as400/dataaccess/mappers/tab1/Tab1Mapper.xml]
### The error may involve eu.mycompany.el20.dq.as400.dataaccess.persistence.tab.Tab1Mapper.selectByExample-Inline
### The error occurred while setting parameters
### SQL: select * from TAB1 WHERE ( D10_SOC = ? and D10_COD_NDG = ? and D10_DATE = ? )
### Cause: java.sql.SQLException: [SQL0443] *N *N
; uncategorized SQLException for SQL []; SQL state [38501]; error code [-443]; [SQL0443] *N *N; nested exception is java.sql.SQLException: [SQL0443] *N *Nstack trace: org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
com.sun.proxy.$Proxy120.selectList(Unknown Source)
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
com.sun.proxy.$Proxy136.selectByExample(Unknown Source)
eu.mycompany.el20.dq.as400.crud.services.tab.BLSTab1.select(BLSTab1.java:46)
it.mycompany.xframe.dq.batch.steps.programstep.ProgramExecutor.processRecord(ProgramExecutor.java:544)
com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep.processRecord(GenericXDBatchStep.java:263)
com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep.processJobStep(GenericXDBatchStep.java:227)
com.ibm.ws.gridcontainer.batch.impl.StepManagerImpl._regularJobBatchLoop(StepManagerImpl.java:1065)
com.ibm.ws.gridcontainer.batch.impl.StepManagerImpl.executeStep(StepManagerImpl.java:390)
com.ibm.ws.gridcontainer.security.actions.ExecuteStepBatchUserPrivilegedAction.executeAction(ExecuteStepBatchUserPrivilegedAction.java:47)
com.ibm.ws.gridcontainer.security.AbstractUserPrivilegedAction.runWithoutSecurity(AbstractUserPrivilegedAction.java:66)
com.ibm.ws.gridcontainer.services.impl.WASRunUnderCredentialServiceImpl.runUnderUserCredential(WASRunUnderCredentialServiceImpl.java:134)
com.ibm.ws.gridcontainer.services.impl.WASRunUnderCredentialServiceImpl.runActionUnderUserCredential(WASRunUnderCredentialServiceImpl.java:386)
com.ibm.ws.gridcontainer.batch.impl.JobManagerImpl._sequentialStepScheduling(JobManagerImpl.java:783)
com.ibm.ws.gridcontainer.batch.impl.JobManagerImpl.executeJob(JobManagerImpl.java:199)
com.ibm.ws.batch.BatchJobControllerWork._runJob(BatchJobControllerWork.java:435)
com.ibm.ws.batch.BatchJobControllerWork.run(BatchJobControllerWork.java:241)
com.ibm.ws.asynchbeans.J2EEContext$RunProxy.run(J2EEContext.java:271)
java.security.AccessController.doPrivileged(AccessController.java:399)
com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:797)
com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:222)
com.ibm.ws.asynchbeans.ABWorkItemImpl.run(ABWorkItemImpl.java:206)
java.lang.Thread.run(Thread.java:790)
The text for message SQL0443 is 'Trigger program or external routine detected an error'.
I would suggest looking at the host database server job for the JDBC connection.
On the IBM i command line, run the command WRKOBJLCK OBJ(<user>) OBJTYPE(*USRPRF) (where <user> is the user profile you're using to do the JDBC connection) and find jobs named QZDASOINIT. These are the database host server jobs.
In these jobs, look at the joblog (or joblog spool file) to find the SQL0443 message ... around that message you should see what the actual error is.

Powercenter SQL1224N error connecting DB2

Im running a workflow in powercenter that is constatnly getting an SQL1224N error.
This process execute a query against one table (POLIZA) with 800k rows, it retrieves the first 10k rows and then it start to execute to another table with 75M rows, at ths moment in DB2 an idle thread error appear but the PWC process still running retrieving the 75M rows, when it is completed (after 20 minutes) the errros comes up related with the first table:
[IBM][CLI Driver] SQL1224N A database agent could not be started to service a request, or was terminated as a result of a database system shutdown or a force command. SQLSTATE=55032
sqlstate = 40003
[IBM][CLI Driver] SQL1224N A database agent could not be started to service a request, or was terminated as a result of a database system shutdown or a force command. SQLSTATE=55032
sqlstate = 40003
Database driver error...
Function Name : Fetch
SQL Stmt : SELECT POLIZA.BSPOL_BSCODCIA, POLIZA.BSPOL_BSRAMOCO
FROM POLIZA
WHERE
EXA01.POLIZA.BSPOL_IDEMPR='0015' for read only with ur
Native error code = -1224
DB2 Fatal Error].
I have a similar process runing against the same 2 tables and it is woking fine where the only difference I can see is that the DB2 user is different.
Any idea how can i fix this?
Regards
The common causes for -1224 are:
Your instance or database has crashed, or
Something/somebody is forcing off your application (FORCE APPLICATION or equivalent)
As for the crash, I think you would know by know. This typically requires a database or instance restart. At any rate, can you please have a look into your DIAGPATH to check for any FODC* directories whose timestamp would match the timestamp of the -1224 errors?
As for the FORCE case, you should find some evidence of the -1224 in db2diag.log. Try searching for the decimal -1224, but also for its hex representation (0xFFFFFB38).

Can I log query execution time in PostgreSQL 8.4?

I want to log each query execution time which is run in a day.
For example like this,
2012-10-01 13:23:38 STATEMENT: SELECT * FROM pg_stat_database runtime:265 ms.
Please give me some guideline.
If you set
log_min_duration_statement = 0
log_statement = all
in your postgresql.conf, then you will see all statements being logged into the Postgres logfile.
If you enable
log_duration
that will also print the time taken for each statement. This is off by default.
Using the log_statement parameter you can control which type of statement you want to log (DDL, DML, ...)
This will produce an output like this in the logfile:
2012-10-01 13:00:43 CEST postgres LOG: statement: select count(*) from pg_class;
2012-10-01 13:00:43 CEST postgres LOG: duration: 47.000 ms
More details in the manual:
http://www.postgresql.org/docs/8.4/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHEN
http://www.postgresql.org/docs/8.4/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT
If you want a daily list, you probably want to configure the logfile to rotate on a daily basis. Again this is described in the manual.
I believe OP was actually asking for execution duration, not the timestamp.
To include the duration in the log output, open pgsql/<version>/data/postgresql.conf, find the line that reads
#log_duration = off
and change it to
log_duration = on
If you can't find the given parameter, just add it in a new line in the file.
After saving the changes, restart the postgresql service, or just invoke
pg_ctl reload -D <path to the directory of postgresql.conf>
e.g.
pg_ctl reload -D /var/lib/pgsql/9.2/data/
to reload the configuration.
I think a better option is to enable pg_stat_statements by enabling the PG stats extension. This will help you to find the query execution time for each query nicely recorded in a view