zkfan / tungsten-replicator

Automatically exported from code.google.com/p/tungsten-replicator
0 stars 0 forks source link

PrimaryKeyFilter throws NullPointerException if it can't find the table #122

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

This appeared once after running the same RQG test as described in Issue 121. 
This issue will be easier to reproduce when Issue 121 is fixed, thus that test 
will hit further issues (like this one) down the road.

What is the expected output?

After test completes slave Tungsten Replicator should be ONLINE.

What do you see instead?

INFO   | jvm 1    | 2011/06/16 20:58:42 | java.lang.NullPointerException
INFO   | jvm 1    | 2011/06/16 20:58:42 |     at 
com.continuent.tungsten.enterprise.replicator.filter.PrimaryKeyFilter.checkForPK
(PrimaryKeyFilter.java:297)
INFO   | jvm 1    | 2011/06/16 20:58:42 |     at 
com.continuent.tungsten.enterprise.replicator.filter.PrimaryKeyFilter.filter(Pri
maryKeyFilter.java:177)
INFO   | jvm 1    | 2011/06/16 20:58:42 |     at 
com.continuent.tungsten.replicator.pipeline.SingleThreadStageTask.runTask(Single
ThreadStageTask.java:337)
INFO   | jvm 1    | 2011/06/16 20:58:42 |     at 
com.continuent.tungsten.replicator.pipeline.SingleThreadStageTask.run(SingleThre
adStageTask.java:148)
INFO   | jvm 1    | 2011/06/16 20:58:42 |     at java.lang.Thread.run(Unknown 
Source)

What is the possible cause?

Judging by the code part which fails (marked below with exclamation mark):

        if (!dbCache.containsKey(tableName) || orc.getTableId() == -1
                || dbCache.get(tableName).getTableId() != orc.getTableId())
        {
            // This table was not processed yet or schema changed since it was
            // cached : fetch information about its primary key
            if (dbCache.remove(tableName) != null && logger.isDebugEnabled())
                logger.debug("Detected a schema change for table "
                        + orc.getSchemaName() + "." + tableName
                        + " - Removing table metadata from cache");
            Table newTable = conn.findTable(orc.getSchemaName(),
                    orc.getTableName());
!           newTable.setTableId(orc.getTableId());
            dbCache.put(tableName, newTable);
        }

It seems, that there is a code path when schema changed and table is not there 
anymore for the PrimaryKeyFilter to find.

What is the proposed solution?

If PrimaryKeyFilter can't find a table, wouldn't it be better if it just 
ignored and did nothing on the events regarding this table? Possibly, later 
applier stages would throw an exception, but that might be more clear than a 
NullPointerException.

Original issue reported on code.google.com by linas.vi...@gmail.com on 17 Jun 2011 at 5:07

GoogleCodeExporter commented 9 years ago

Original comment by linas.vi...@gmail.com on 17 Jun 2011 at 5:07

GoogleCodeExporter commented 9 years ago
Reproduction (node1 - master, SQL - slave):

node1 [localhost] {tungsten} (pricing) > create table ttt (i int);
Query OK, 0 rows affected (0.04 sec)

node1 [localhost] {tungsten} (pricing) > insert into ttt values (1);
Query OK, 1 row affected (0.02 sec)

node1 [localhost] {tungsten} (pricing) > update ttt set i = 2 where i = 1;

SQL> drop table mysqlrep.ttt;

node1 [localhost] {tungsten} (pricing) > update ttt set i = 3 where i = 2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

/* Slave crashes with applier error */

./trepctl online

/* Error changes (!) Now slave crashes with PrimaryKeyFilter error above */

Original comment by linas.vi...@gmail.com on 23 Jun 2011 at 4:44

GoogleCodeExporter commented 9 years ago

Original comment by linas.vi...@gmail.com on 23 Jun 2011 at 4:45

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r290.

Original comment by stephane...@gtempaccount.com on 4 Jul 2011 at 1:28