question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE on INSERT into column in altered table

See original GitHub issue

CrateDB version

4.5.1

CrateDB setup information

Number of nodes: 3 12 GB heap

Steps to Reproduce

CREATE TABLE IF NOT EXISTS "doc"."0x001" (
   "ts" TIMESTAMP WITHOUT TIME ZONE,
   "stream_id" TEXT,
   "01_01" OBJECT,
   "01_02" OBJECT,
   "01_03" OBJECT,
....
"ts_partition" TIMESTAMP WITHOUT TIME ZONE GENERATED ALWAYS AS _cast(date_trunc('quarter', 'UTC', "ts"), 'timestamp without time zone')
)
CLUSTERED BY ("stream_id") INTO 6 SHARDS
PARTITIONED BY ("ts_partition")
WITH (
   "allocation.max_retries" = 5,
   "blocks.metadata" = false,
   "blocks.read" = false,
   "blocks.read_only" = false,
   "blocks.read_only_allow_delete" = false,
   "blocks.write" = false,
   codec = 'default',
   column_policy = 'strict',
   "mapping.total_fields.limit" = 1000,
   max_ngram_diff = 1,
   max_shingle_diff = 3,
   number_of_replicas = '0-1',
   "routing.allocation.enable" = 'all',
   "routing.allocation.total_shards_per_node" = -1,
   "store.type" = 'fs',
   "translog.durability" = 'REQUEST',
   "translog.flush_threshold_size" = 536870912,
   "translog.sync_interval" = 5000,
   "unassigned.node_left.delayed_timeout" = 60000,
   "write.wait_for_active_shards" = '1'
) 

Inserting works ok so far, then altered table: alter table "doc"."0x001" add column "02_0815" OBJECT;

everything still works ok, but after a view days, we cannot insert into the new column 02_0815 anymore: error: NullpointerException[null], code: 5000, trace: Java.Lang.NullpointerException We insert via http and do not always get this error, but most of the time Status 200, and rowcount(s) : -2 Also tried inserting via the AdminUI, same result, NullpointerException[null] ! But: inserting into all the other columns still works !

Tried to create another OBJECT column in this table, same result. At this point the table has:

  • 707 columns
  • 132 MIO records
  • Size 19.1 GB
  • Shards 48

The sys.jobs_log table shows the insert statements, but error column is always null.

We then created another table with just 1 OBJECT column (and the other columns from the first table): inserting works as expected.

Expected Result

INSERTING works or get a decent error message.

Actual Result

error: NullpointerException[null], code: 5000, trace: Java.Lang.NullpointerException

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
heyokacommented, Sep 9, 2021

For clarification: the number of columns I posted above is the result of

select COUNT(*)
from information_schema.columns
where table_schema = 'doc' and table_name = '0x001'

707

We do NOT have more than 700 OBJECT(DYNAMIC) columns in the table

0reactions
proddatacommented, Sep 9, 2021

Tried to replicate this with a restore of the affected table with

NullPointerException[Cannot invoke “Object.equals(Object)” because “sourceValue”

when trying to insert

edit: Seems like something is breaking the table (schema / metadata). Even after deleting all partition the INSERT fails. While on a freshly created it succeeds

edit2: @seut stacktrace:

java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because "sourceValue" is null
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:233) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:229) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:229) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:218) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.updateTemplate(TransportSchemaUpdateAction.java:208) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction$1.execute(TransportSchemaUpdateAction.java:168) ~[crate-server.jar:?]
	at org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:45) ~[crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:701) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:318) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:213) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:150) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:153) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:191) [crate-server.jar:?]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:259) [crate-server.jar:?]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:222) [crate-server.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
	at java.lang.Thread.run(Thread.java:831) [?:?]
[2021-09-10T00:26:28,716][DEBUG][i.c.a.s.SQLOperations    ] [Dent de Savigny] method=bind portalName= statementName= params=[]
[2021-09-10T00:26:28,716][DEBUG][i.c.a.s.SQLOperations    ] [Dent de Savigny] method=describe type=P portalOrStatement=
[2021-09-10T00:26:28,717][DEBUG][i.c.a.s.SQLOperations    ] [Dent de Savigny] method=execute portalName= maxRows=0
[2021-09-10T00:26:28,773][DEBUG][o.e.c.s.MasterService    ] [Dent de Savigny] executing cluster state update for [update-template-mapping]
[2021-09-10T00:26:28,775][TRACE][o.e.c.s.MasterService    ] [Dent de Savigny] failed to execute cluster state update (on version: [53], uuid: [uREWCMS0TI-itsfCLPTRsw]) for [update-template-mapping]
nodes: 
   {Dent de Savigny}{Iuzqp1PZSWiy5b1uOTstzw}{cOkTccu3RwaKT6o3Hj8xhw}{127.0.0.1}{127.0.0.1:4300}{http_address=127.0.0.1:4200}, local, master
routing_table (version 6):
-- index [[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g/_Qt5feNxRRqqRffOI16U8Q]]
----shard_id [.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][0]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][0], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=Iz8gnwnbSJW5m_vJ4TOcvQ]
----shard_id [.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][1]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][1], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=yZ6lJMcfQCKtHZSTaQamQA]
----shard_id [.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][2]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][2], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=EP2E0sBCSwWjrVcoOIfLbQ]
----shard_id [.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][3]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][3], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=Wd5PqJekSbWGKExI64Hubg]
----shard_id [.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][4]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][4], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=m82STN3jRwKEfYBVuVrdFg]
----shard_id [.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][5]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][5], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=EX4IDXZqT121MecEHNza8g]

routing_nodes:
-----node_id[Iuzqp1PZSWiy5b1uOTstzw][V]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][4], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=m82STN3jRwKEfYBVuVrdFg]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][3], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=Wd5PqJekSbWGKExI64Hubg]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][1], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=yZ6lJMcfQCKtHZSTaQamQA]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][5], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=EX4IDXZqT121MecEHNza8g]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][2], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=EP2E0sBCSwWjrVcoOIfLbQ]
--------[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][0], node[Iuzqp1PZSWiy5b1uOTstzw], [P], s[STARTED], a[id=Iz8gnwnbSJW5m_vJ4TOcvQ]
---- unassigned

java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because "sourceValue" is null
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:233) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:229) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:229) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.mergeIntoSource(TransportSchemaUpdateAction.java:218) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction.updateTemplate(TransportSchemaUpdateAction.java:208) ~[crate-server.jar:?]
	at io.crate.execution.ddl.TransportSchemaUpdateAction$1.execute(TransportSchemaUpdateAction.java:168) ~[crate-server.jar:?]
	at org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:45) ~[crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:701) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:318) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:213) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:150) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:153) [crate-server.jar:?]
	at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:191) [crate-server.jar:?]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:259) [crate-server.jar:?]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:222) [crate-server.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
	at java.lang.Thread.run(Thread.java:831) [?:?]
[2021-09-10T00:26:28,776][TRACE][o.e.t.TaskManager        ] [Dent de Savigny] unregister task for id: 47
[2021-09-10T00:26:28,776][DEBUG][o.e.c.s.MasterService    ] [Dent de Savigny] took [0s] to compute cluster state update for [update-template-mapping]
[2021-09-10T00:26:28,776][DEBUG][o.e.c.s.MasterService    ] [Dent de Savigny] took [0s] to notify listeners on unchanged cluster state for [update-template-mapping]
[2021-09-10T00:26:28,777][TRACE][i.c.e.d.u.TransportShardUpsertAction] [Dent de Savigny] FAILURE - id=VsOrzHsBd_v1qJKdYDX4, primary_term=0, seq_no=-2
[2021-09-10T00:26:28,777][DEBUG][i.c.e.d.u.TransportShardUpsertAction] [Dent de Savigny] Failed to execute upsert shardId=[.partitioned.0x5bc2.04732dhi6ko3idpm60o30c1g][0] id=VsOrzHsBd_v1qJKdYDX4 error=java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because "sourceValue" is null
Read more comments on GitHub >

github_iconTop Results From Across the Web

HiveQL ALTER TABLE: NullPointerException, INSERT INTO
I'm having trouble with the INSERT INTO and ALTER TABLE commands. I found the following code in my notes, which indicates it probably...
Read more >
SQL Server ALTER TABLE ADD Column overview
In this article, we will explore SQL Server ALTER TABLE ADD Column statements to add column(s) to an existing table.
Read more >
Unable to Update NULL columns after Schema Evolution with ...
Once the table schema is evolved by adding new columns or by renaming columns. The resulting added/modified column values for existing rows ...
Read more >
SQL ALTER TABLE Statement - W3Schools
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used...
Read more >
[#HIVE-16877] NPE when issue query like alter table ... - Apache
After HIVE-8839 in 1.1.0 support "alter table ... cascade" to cascade table changes to partitions as well. But NPE thrown when issue query...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found