Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supportsTransactionalSchema cause metadata sync problem in multi jvms #509

Open
lalicw opened this issue Jun 1, 2024 · 7 comments
Open

Comments

@lalicw
Copy link

lalicw commented Jun 1, 2024

when we add graph change notify support by kafka for database not postgre, we found that metadata of different nodes is not the same in multi jvm nodes senario.

we implement notifyChange by send kafka message, and all nodes listen the same topic to recieve change and notifyFromJson.

but we found TestMultipleThreadMultipleJvm.java we reproduce the problem.
and the root cause is the code in Topology.java as below:

 this.sqlgGraph.tx().afterRollback(() -> {
            if (this.sqlgGraph.getSqlDialect().supportsTransactionalSchema()) {
                afterRollback();
            } else {
                afterCommit();
            }
        });

when the database not supportsTransactionalSchema, this code indicate that use commit instead of rollback, and this will cause the change is not be send.

@lalicw
Copy link
Author

lalicw commented Jun 3, 2024

after more analyze, i found that if we invoke after Commit in afterRollback which not supportsTransactionalSchema. this will case the data in metadata table was rollback, but the schema created, then no change notification and other node cannot create schema anymore.
That's why the metadata is not sync anymore.

@pietermartin
Copy link
Owner

when we add graph change notify support by kafka for database not postgre

I am not fully understanding what database you are running on?

@lalicw
Copy link
Author

lalicw commented Jun 4, 2024

when we add graph change notify support by kafka for database not postgre

I am not fully understanding what database you are running on?

we use mariadb, and i found the root cause is that when we rollback, the data in V_log will rollback too, and we even send the notification but cannot load change anymore.

@pietermartin
Copy link
Owner

Ok, ddl statments are not transactional on MariaDb, so its strongly advised to run schema changes in its own transaction to reduce failures leaving the db in a undefined state.

Are you creating schema elements as part of a bigger transaction, or the failure/rollback happens because of the ddl/schema change statement itself?

Are you creating the schema using Sqlg's topology api?
What version of Sqlg are you on?

@lalicw
Copy link
Author

lalicw commented Jun 4, 2024

Ok, ddl statments are not transactional on MariaDb, so its strongly advised to run schema changes in its own transaction to reduce failures leaving the db in a undefined state.

Are you creating schema elements as part of a bigger transaction, or the failure/rollback happens because of the ddl/schema change statement itself?

Are you creating the schema using Sqlg's topology api? What version of Sqlg are you on?

actually most of the time we will not create schema user sqlg api, but we will create table use sqlg api.
we just try to run the TestMultipleThreadMultipleJvm.java to make sure the notification is sent.
so we cannot just use afterCommit instead of afterRollback
sqlg version:3.0

@pietermartin
Copy link
Owner

Ok, I'd have to investigate it further,

after more analyze, i found that if we invoke after Commit in afterRollback which not supportsTransactionalSchema. this will case the data in metadata table was rollback, but the schema created, then no change notification and other node cannot create schema anymore. That's why the metadata is not sync anymore.

MariaDb does not support transactional schema, so afterCommit is already called this.sqlgGraph.tx().afterRollback(..)

Can you explain this more, where are you invoking afterCommit in afterRollback ?

@lalicw
Copy link
Author

lalicw commented Jun 6, 2024

Ok, I'd have to investigate it further,

after more analyze, i found that if we invoke after Commit in afterRollback which not supportsTransactionalSchema. this will case the data in metadata table was rollback, but the schema created, then no change notification and other node cannot create schema anymore. That's why the metadata is not sync anymore.

MariaDb does not support transactional schema, so afterCommit is already called this.sqlgGraph.tx().afterRollback(..)

Can you explain this more, where are you invoking afterCommit in afterRollback ?

In Topology.java line 539

        this.sqlgGraph.tx().afterRollback(() -> {
            if (this.sqlgGraph.getSqlDialect().supportsTransactionalSchema()) {
                afterRollback();
            } else {
                afterCommit();
            }
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants